MudBlazor/MudBlazor

Add required asterisk and validation support to MudField

开放

#1,116 创建于 2021年3月7日

 (3 条评论) (0 个反应) (0 位负责人)C# (1,631 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (10,394 个星标)
PR 合并指标
 (平均合并 6天 6小时) (30 天内合并 108 个 PR)

描述

As ever, a suggestion that might improve an already great product but only if you feel it would be a benefit to the wider user base.

I tend to use MudField as a wrapper for other elements such as a radio button group or a group of a few elements relating to a single result (e.g. two fields for weight and height together in a 'BMI Calculator' MudField).

As such, two things I think would be useful

  • The ability to add the superscript * to the label to indicate that the contents of the MudField (e.g. a Radio Button Group) are mandatory to keep the look and feel the same across the app.
  • Having a "Validator" option for the MudField.

I currently address the second requirement by including a hidden MudTextField in the form and then setting the Error parameter on the visible MudField to

_formErrors.Contains(String_Value_Associated_With_Hidden_MudTextField_Error)

I'm guessing there's probably a better way to do this?

贡献者指南