-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue
Milestone
Description
Describe the bug
When using data annotations on a model with the <EditForm> component, DateTime does not display the correct [Display] name set on the annotated model.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core 3.0 Preview 6
- Create an empty project and use the following code:
public class MyModel {
[Required]
[Display(Name = "Received Date")]
public DateTime ReceivedDate { get; set; }
}<EditForm Model="@MyModel" OnValidSubmit="@HandleValidSubmit">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="Date Received">Date Received</span>
</div>
<InputDate Class="form-control" Id="DateReceived" @bind-Value="@MyModel.ReceivedDate" />
<div class="invalid-feedback d-block">
<ValidationMessage For="@(() => MyModel.ReceivedDate)" />
</div>
</div>
</EditForm>Expected behavior
The error message should display "The Received Date field must be a date."
Actual behavior
The error message displays: "The ReceivedDate field must be a date." (Notice the lack of space on the field name).
Workaround
You can manually set the ParsingErrorMessage attribute as shown here:
<InputDate ParsingErrorMessage="The Received Date field must be a valid date." Class="form-control" Id="DateReceived" @bind-Value="@MyModel.ReceivedDate" />Screenshots
Additional context
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview6-012264
Commit: be3f0c1a03
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\
Host (useful for support):
Version: 3.0.0-preview6-27804-01
Commit: fdf81c6faf
.NET Core SDKs installed:
2.1.604 [C:\Program Files\dotnet\sdk]
2.1.700-preview-009618 [C:\Program Files\dotnet\sdk]
2.1.800-preview-009677 [C:\Program Files\dotnet\sdk]
2.1.800-preview-009696 [C:\Program Files\dotnet\sdk]
3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.help wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issue


