I have a form:
<EditForm Model="@Model" OnValidSubmit="@SubmitSuccess" OnInvalidSubmit="@SubmitFailure" Context="editContext">
<DataAnnotationsValidator/>
//Here the controls
</EditForm>
In this particular form I have a required property but this property is set in code and not from an input control in the form.
I have a property:
private EditContext editContext;
And in OnParamatersSet()
I do:
editContext = new EditContext(Model);
I have custom data annotations for validation and they are displayed correctly. I'm trying to clear the validation messages in code and I have tried:
Recreating the edit context:
editContext = new EditContext(Model);
await InvokeAsync(StateHasChanged);
and
Notify the property changed:
editContext.NotifyFieldChanged("Property");
await InvokeAsync(StateHasChanged);
But both are not working.
So how can I successfully clear the validation messages?