ARTICLE AD BOX
I am working with MudBlazor and having an issue with MudForm. When switching an item to "Edit" mode, I fetch the data and try to clear any existing validation errors from previous interactions, but the validation messages persist on the UI.
In my logic, I check the category of the item and then call ResetValidation() and ResetAsync() on the corresponding form reference. However, the form still shows red error borders or messages.
Here is the relevant code snippet:
private async Task HandleEdit(DatItem item) { var detail = await GetDetailDat(item.Id); if (detail == null) return; var isDatO = detail.MaNhom == "DAT_O"; if (isDatO) { // ... mapping data logic ... // Trying to clear validation here InvokeAsync(() => _formMud.ResetValidation()); _formMud.ResetAsync(); } else { // ... mapping data logic ... // Same reset logic for the other form InvokeAsync(() => _formMudK.ResetValidation()); _formMudK.ResetAsync(); } }What I have tried:
Using _formMud.ResetValidation() to only clear errors.
Using _formMud.ResetAsync() to reset both values and validation.
Wrapping the call in InvokeAsync(() => ...) to ensure it runs on the UI thread.
I've verified that _formMud is correctly @bind-Target to the MudForm in the .razor file.
The Problem: Even after these calls, the form fields still display validation errors from the previous state. It seems like the reset happens before the new data is fully bound, or the UI doesn't refresh the validation state correctly.
How can I properly force MudForm to clear all validation states when loading new data into the form?
