Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions aspnetcore/blazor/forms/input-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,18 @@ The validation summary displays the friendly name when the field's value is inva

:::moniker range=">= aspnetcore-11.0"

The <xref:Microsoft.AspNetCore.Components.Forms.DisplayName%601> component can be used to display property names from metadata attributes. The [`[Display]` attribute](xref:System.ComponentModel.DataAnnotations.DisplayAttribute) on the model class property is supported:
The <xref:Microsoft.AspNetCore.Components.Forms.DisplayName%601> component can be used to display property names from metadata attributes.
Comment thread
ilonatommy marked this conversation as resolved.

Use the `DisplayName` component in labels or table headers:

```razor
<label>
<DisplayName For="@(() => Model!.ProductionDate)" />
<InputDate @bind-Value="Model!.ProductionDate" />
</label>
```

The [`[Display]` attribute](xref:System.ComponentModel.DataAnnotations.DisplayAttribute) on the model class property is supported:
Comment thread
ilonatommy marked this conversation as resolved.

```csharp
Comment thread
ilonatommy marked this conversation as resolved.
[Required, Display(Name = "Production Date")]
Expand All @@ -478,15 +489,6 @@ public DateTime ProductionDate { get; set; }

Between the two approaches, the `[Display]` attribute is recommended, which makes additional properties available. The `[Display]` attribute also enables assigning a resource type for localization. When both attributes are present, `[Display]` takes precedence over `[DisplayName]`. If neither attribute is present, the component falls back to the property name.
Comment thread
ilonatommy marked this conversation as resolved.
Outdated

Use the `DisplayName` component in labels or table headers:
Comment thread
ilonatommy marked this conversation as resolved.

```razor
<label>
<DisplayName For="@(() => Model!.ProductionDate)" />
<InputDate @bind-Value="Model!.ProductionDate" />
</label>
```

:::moniker-end

## Error message template support
Expand Down
Loading