-
Notifications
You must be signed in to change notification settings - Fork 27k
feat(forms): update submit function to accept options object #66810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Changes the `submit` function signature to accept a `FormSubmitOptions` object instead of a direct action callback. This allows for more flexibility, including: - `action`: The standard submit action to perform with the data. - `onInvalid`: A callback to execute when the submit action is not triggered due to failing validation - `ignoreValidators`: Controls whether pending validators or invalid validators should be ignored Also updates the return value of `submit` to a `Promise<boolean` to indicate submission success.
Updates FormOptions to accept a submission configuration object. This allows defining default submit options (action, validation behavior, etc.) when creating the form, which can be overridden when calling submit().
| ...(options ?? {}), | ||
| } as Partial<FormSubmitOptions<TModel>>); | ||
| const action = opts?.action; | ||
| if (!action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may have missed the discussion about this, but is the desire to support two ways of specifying the submit action worth the complexity/error here?
Did we consider only supporting it at the form() level? Is there are case where users would define the form() action, and override it with local submit() behavior?
Changes the
submitfunction signature to accept aFormSubmitOptionsobject instead of a direct action callback.This allows for more flexibility, including:
action: The standard submit action to perform with the data.onInvalid: A callback to execute when the submit action is not triggered due to failing validationignoreValidators: Controls whether pending validators or invalid validators should be ignoredAlso updates the return value of
submitto aPromise<booleanto indicate submission success.Updates
FormOptionsto accept asubmissionconfiguration object.This allows defining default submit options (action, validation behavior, etc.)
when creating the form, which can be overridden when calling
submit().