parent
4a813773d0
commit
ed4896d1fd
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
displayMetadata.Description = () => displayAttribute.GetDescription();
|
||||
}
|
||||
|
||||
// DisplayFormat
|
||||
// DisplayFormatString
|
||||
if (displayFormatAttribute != null)
|
||||
{
|
||||
displayMetadata.DisplayFormatString = displayFormatAttribute.DataFormatString;
|
||||
|
|
@ -87,6 +87,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
displayMetadata.DisplayName = () => displayAttribute.GetName();
|
||||
}
|
||||
|
||||
// EditFormatString
|
||||
if (displayFormatAttribute != null && displayFormatAttribute.ApplyFormatInEditMode)
|
||||
{
|
||||
displayMetadata.EditFormatString = displayFormatAttribute.DataFormatString;
|
||||
|
|
@ -233,8 +234,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
var display = field.GetCustomAttribute<DisplayAttribute>(inherit: false);
|
||||
if (display != null)
|
||||
{
|
||||
// Note [Display(Name = "")] is allowed.
|
||||
var name = display.GetName();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
if (name != null)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
typeof(EnumWithDisplayNames),
|
||||
new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("cero", "0"),
|
||||
new KeyValuePair<string, string>(string.Empty, "0"),
|
||||
new KeyValuePair<string, string>(nameof(EnumWithDisplayNames.One), "1"),
|
||||
new KeyValuePair<string, string>("dos", "2"),
|
||||
new KeyValuePair<string, string>("tres", "3"),
|
||||
|
|
@ -436,7 +436,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
typeof(EnumWithDisplayNames?),
|
||||
new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("cero", "0"),
|
||||
new KeyValuePair<string, string>(string.Empty, "0"),
|
||||
new KeyValuePair<string, string>(nameof(EnumWithDisplayNames.One), "1"),
|
||||
new KeyValuePair<string, string>("dos", "2"),
|
||||
new KeyValuePair<string, string>("tres", "3"),
|
||||
|
|
@ -708,7 +708,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
|
|||
[Display(ShortName = "uno")]
|
||||
One = 1,
|
||||
|
||||
[Display(Name = "cero")]
|
||||
[Display(Name = "")]
|
||||
Zero = 0,
|
||||
|
||||
[Display(Name = "menos uno")]
|
||||
|
|
|
|||
Loading…
Reference in New Issue