Recommended Types
Form Composition API Reference
FormApi Reference
- form.setFieldValue()
- form.getFieldValue()
- form.resetField()
- form.swapFieldValues()
- form.moveFieldValue()
- form.pushFieldValue()
- form.insertFieldValue()
- form.clearFieldValues()
- form.removeFieldValue()
- form.filterFieldValues()
- form.handleSubmit()
- form.reset()
- FormApi
- FormOptions
- FormState
- FormResetOptions
- FormSubmitContext
- FormSubmitInvalidContext
Form Listener API Reference
Field Listener API Reference
BaseSubmitContext
Defined in: FormApi/formSubmit.public.ts:103
Provides the cancellation signal and error helpers for form and form group onSubmit callbacks.
Extended by#
Type Parameters#
TFormData#
TFormData
Library-managed. Do not specify explicitly.
Properties#
createErrorMap#
createErrorMap: CreateSubmitErrorMapFn<TFormData>;Defined in: FormApi/formSubmit.public.ts:172
Builds a mutable map of submission errors from optional initial errors.
- If you already have errors ready to return, use createValidationError.
- If you want to return Standard Schema errors, use parseIssues.
- Add errors with addFormError and addFieldError.
- Return the map from onSubmit to report its errors.
- The form entry targets the submitting form or group.
- Field paths are relative to the submitting form or group.
- An empty map indicates success.
Example#
formOptions({
defaultValues: { name: '' },
onSubmit: async ({ value, createErrorMap }) => {
const errors = createErrorMap()
if (await nameIsTaken(value.name)) {
errors.addFieldError('name', 'Name is already taken')
}
return errors
},
})createValidationError#
createValidationError: CreateValidationErrorFn<TFormData>;Defined in: FormApi/formSubmit.public.ts:144
Wraps existing errors so onSubmit can return them as validation errors. Calling this helper alone does not update validation state.
Accepts error messages, issue objects, arrays of errors, or an error map. For a group, field paths in an error map are relative to the group.
- If you want to build or edit errors by field, use createErrorMap.
- If you want to return Standard Schema errors, use parseIssues.
Example#
formOptions({
defaultValues: { name: '' },
onSubmit: async ({ value, createValidationError }) => {
if (await nameIsTaken(value.name)) {
return createValidationError('Name is already taken')
}
await saveProfile(value)
},
})parseIssues#
parseIssues: ParseSubmitIssuesFn<TFormData>;Defined in: FormApi/formSubmit.public.ts:200
Converts Standard Schema issues into a mutable error map to return from onSubmit.
- If you want to return your own error messages or an existing error map, use createValidationError.
- If you want to build or edit errors by field, use createErrorMap.
- Uses the captured submission values to resolve field paths.
- Issues without a field path become form or group errors.
- For a group, issue paths are relative to the group.
- Return the map to report its errors. An empty map indicates success.
Example#
formOptions({
defaultValues: { name: '' },
onSubmit: async ({ value, parseIssues }) => {
const result = parseSchema(mySchema, value)
if (!result.success) {
return parseIssues(result.issues)
}
await saveProfile(result.data)
},
})signal#
signal: AbortSignal;Defined in: FormApi/formSubmit.public.ts:118
Signals when this submission attempt is invalidated.
- A newer submission of the same form or group aborts the signal.
- A reset or unmount also aborts it.
- Field edits during a submission do not abort the signal.
- The same signal is passed to this attempt's onSubmitInvalid, if it runs.
Remarks#
Important: Aborting prevents submission results from updating form or group state. Callbacks already started are still awaited, and their exceptions retain normal handling. Use the signal to stop external work that supports cancellation.