EditForm Model vs EditContext

598 Views Asked by At

What are differences and benefits of Model and EditContext for EditForm in Blazor?

in a project type of server side blazor, if we have custom validations in the form and want to validate the form, what is the best and optimized way to achieve that?

1

There are 1 best solutions below

0
On

You could check EditForm class and the description of Model property:

Specifies the top-level model object for the form. An edit context will be constructed for this model. If using this parameter, do not also supply a value for EditContext.

the decription of OnInvalidSubmit event:

A callback that will be invoked when the form is submitted and the EditContext is determined to be invalid.

The form would always be validated based on an EditContext,if you haven't bind the EditContext in your EditFrom,it would create one based on your Model

For custom validation,you could follow this document