mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 13:08:23 +08:00
fix(module: form): DisplayName for FormItem will be not default to property name (#1738)
* fix(module: form): DisplayName for FormItem will be not default to property name * add a demo for display name attribute
This commit is contained in:
parent
977633ae93
commit
1758181dea
@ -22,8 +22,8 @@ namespace AntDesign.Core.Reflection
|
||||
this.PropertyInfo = propertyInfo;
|
||||
this.RequiredAttribute = propertyInfo.GetCustomAttribute<RequiredAttribute>(true);
|
||||
this.DisplayName = propertyInfo.GetCustomAttribute<DisplayNameAttribute>(true)?.DisplayName ??
|
||||
propertyInfo.GetCustomAttribute<DisplayAttribute>(true)?.Name ??
|
||||
propertyInfo.Name;
|
||||
propertyInfo.GetCustomAttribute<DisplayAttribute>(true)?.Name;
|
||||
|
||||
this.PropertyName = PropertyInfo.Name;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
@using System.ComponentModel.DataAnnotations;
|
||||
@using System.Text.Json;
|
||||
@using System.ComponentModel
|
||||
|
||||
<Form Model="@model"
|
||||
OnFinish="OnFinish"
|
||||
OnFinishFailed="OnFinishFailed"
|
||||
LabelColSpan="8"
|
||||
WrapperColSpan="16">
|
||||
<FormItem Label="Username">
|
||||
<FormItem>
|
||||
<Input @bind-Value="@context.Username" />
|
||||
</FormItem>
|
||||
<FormItem Label="Password">
|
||||
@ -25,7 +26,7 @@
|
||||
{
|
||||
public class Model
|
||||
{
|
||||
[Required]
|
||||
[Required, DisplayName("User Name")]
|
||||
public string Username { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user