I use the following to do validations on a form in blazor(server)
<EditForm Model="@place" OnValidSubmit="HandleValidSubmit" Context="placesEdit" >
<DataAnnotationsValidator />
<InputText @bind-Value="place.Name"/>
<ValidationMessage For="() => place.Name" />
</EditForm>
@{place=new Place(); }
the property Name as a [required] - Attribute. This works fine. When submitting the form I see the error message and the HandleValidSubmit isn't called
But when I try to do the same with a List the validation isn't happening. No error is displayed and HandleValidSubmit is called instead even if the requirements are not met:
<EditForm Model="@places" OnValidSubmit="HandleValidSubmit" Context="placesEdit" >
<DataAnnotationsValidator />
@foreach(var place in places) {
<InputText @bind-Value="place.Name"/>
<ValidationMessage For="() => place.Name" />
}
</EditForm>
@{places=new List<Place>(); }
What has do be done that the Validator also works in the loop?