0

I have multiple EditForms on my page, each in a separate tab. If one form has a validation error I still want to submit one of the other forms if that form is fine. Currently the default behavior is that if there is any validation error on the page for an EditForm then none can be submitted. How can I stop this behavior, or detect an issue in another form? As currently I don't know how to capture this, clicking submit on form B if form A has issue to the user nothing happens.

Eaxmple form:

<EditForm Context="formContext_Account" Model="@_voipAccount_Account" OnValidSubmit="@SubmitForm_Account">

    <Blazorize.ValidationSummary />
    <DataAnnotationsValidator />

    <label for="portNumber">Number to port</label>
    <div class="input-group">
         <InputText class="form-control" id="NumberToPort" Value="@_voipAccount_Account.NumberToPort" ValueExpression="() => _voipAccount_Account.NumberToPort" />                                                
     </div>

     <ValidationMessage For="@(()=>_voipAccount_Account.NumberToPort)" />
     <button type="submit" class="btn btn-info">Save changes</button>

</EditForm>

Each form has differing Context, Model, and OnValidSubmit, yet still any error in one form prohibits the submission of another valid form.

I'm trying to figure out how to either ignore errors in other forms, OR detect a validation error in any form so I can display a message informing the user to check unsubmitted changes they've made elsewhere.

Vereonix
  • 1,341
  • 5
  • 27
  • 54
  • You probably need to separate out the data from the UI components. See this article that demonstrates how to do this. https://stackoverflow.com/questions/75157902/managing-state-and-preventing-blazor-navigation-in-an-edit-form You can then have a data edit context per form and make the appropriate decisions based on the state of each. – MrC aka Shaun Curtis Feb 03 '23 at 19:00
  • Check this solution maybe it solves the problem: 1) remove all OnValidSubmit from EditForm. 2) add OnClick to submit button and change the type of the button from "submit" to "button". – mRizvandi Feb 06 '23 at 15:41

0 Answers0