EditForm renders the Blazor form element that other form components depend on. Its Model attribute identifies the object being edited and validated, while bound inputs update that object after interaction. section 36.2
Choose the submission callback that matches the behavior you need:
- Use OnValidSubmit when the model passes validation; use OnInvalidSubmit when submission fails validation. section 36.2.3
- Use OnSubmit to handle the form submission before validation is performed. section 36.2.3
- Place a conventional submit button inside EditForm so it handles the rendered form's onsubmit event. section 36.2.3
Editing and validating a product
An administration editor binds EditForm to Product, adds DataAnnotationsValidator, displays ValidationMessage elements, and saves through OnValidSubmit="SaveProduct". The same component serves create and edit routes; successful persistence returns to the product list. section 10.3.5
Table 36.7 The EditForm events (view table figure)
| Name |
Description |
|---|---|
| OnValidSubmit |
This event is triggered when the form is submitted and the form data passes validation. |
| OnInvalidSubmit |
This event is triggered when the form is submitted and the form data fails validation. |
| OnSubmit |
This event is triggered when the form is submitted and before validation is performed. |
Use the event table to compare valid, invalid, and pre-validation submission behavior. section 36.2.3
