Defined in: packages/form-core/src/FormApi.ts:668
A class representing the Form API. It handles the logic and interactions with the form state.
Normally, you will not need to create a new FormApi instance directly. Instead, you will use a framework hook/function like useForm or createForm to create a new instance for you that uses your framework's reactivity model. However, if you need to create a new instance manually, you can do so by calling the new FormApi constructor.
• TFormData
• TOnMount extends undefined | FormValidateOrFn<TFormData>
• TOnChange extends undefined | FormValidateOrFn<TFormData>
• TOnChangeAsync extends undefined | FormAsyncValidateOrFn<TFormData>
• TOnBlur extends undefined | FormValidateOrFn<TFormData>
• TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>
• TOnSubmit extends undefined | FormValidateOrFn<TFormData>
• TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>
• TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>
• TSubmitMeta = never
new FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>(opts?): FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>
new FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>(opts?): FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>
Defined in: packages/form-core/src/FormApi.ts:755
Constructs a new FormApi instance with the given form options.
FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>
FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>
baseStore: Store<BaseFormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>>;
baseStore: Store<BaseFormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>>;
Defined in: packages/form-core/src/FormApi.ts:695
fieldInfo: Record<DeepKeys<TFormData>, FieldInfo<TFormData>>;
fieldInfo: Record<DeepKeys<TFormData>, FieldInfo<TFormData>>;
Defined in: packages/form-core/src/FormApi.ts:725
A record of field information for each field in the form.
fieldMetaDerived: Derived<Record<DeepKeys<TFormData>, AnyFieldMeta>>;
fieldMetaDerived: Derived<Record<DeepKeys<TFormData>, AnyFieldMeta>>;
Defined in: packages/form-core/src/FormApi.ts:708
options: FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta> = {};
options: FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta> = {};
Defined in: packages/form-core/src/FormApi.ts:683
The options for the form.
store: Derived<FormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>>;
store: Derived<FormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>>;
Defined in: packages/form-core/src/FormApi.ts:709
get state(): FormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>
get state(): FormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>
Defined in: packages/form-core/src/FormApi.ts:727
FormState<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer>
deleteField<TField>(field): void
deleteField<TField>(field): void
Defined in: packages/form-core/src/FormApi.ts:1777
• TField extends string
TField
void
getAllErrors(): object
getAllErrors(): object
Defined in: packages/form-core/src/FormApi.ts:2015
Returns form and field level errors
object
fields: Record<DeepKeys<TFormData>, {
errorMap: ValidationErrorMap;
errors: unknown[];
}>;
fields: Record<DeepKeys<TFormData>, {
errorMap: ValidationErrorMap;
errors: unknown[];
}>;
form: object;
form: object;
errorMap: FormValidationErrorMap<UnwrapFormValidateOrFn<TOnMount>, UnwrapFormValidateOrFn<TOnChange>, UnwrapFormAsyncValidateOrFn<TOnChangeAsync>, UnwrapFormValidateOrFn<TOnBlur>, UnwrapFormAsyncValidateOrFn<TOnBlurAsync>, UnwrapFormValidateOrFn<TOnSubmit>, UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>, UnwrapFormAsyncValidateOrFn<TOnServer>>;
errorMap: FormValidationErrorMap<UnwrapFormValidateOrFn<TOnMount>, UnwrapFormValidateOrFn<TOnChange>, UnwrapFormAsyncValidateOrFn<TOnChangeAsync>, UnwrapFormValidateOrFn<TOnBlur>, UnwrapFormAsyncValidateOrFn<TOnBlurAsync>, UnwrapFormValidateOrFn<TOnSubmit>, UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>, UnwrapFormAsyncValidateOrFn<TOnServer>>;
errors: (
| UnwrapFormValidateOrFn<TOnMount>
| UnwrapFormValidateOrFn<TOnChange>
| UnwrapFormAsyncValidateOrFn<TOnChangeAsync>
| UnwrapFormValidateOrFn<TOnBlur>
| UnwrapFormAsyncValidateOrFn<TOnBlurAsync>
| UnwrapFormValidateOrFn<TOnSubmit>
| UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>
| UnwrapFormAsyncValidateOrFn<TOnServer>)[];
errors: (
| UnwrapFormValidateOrFn<TOnMount>
| UnwrapFormValidateOrFn<TOnChange>
| UnwrapFormAsyncValidateOrFn<TOnChangeAsync>
| UnwrapFormValidateOrFn<TOnBlur>
| UnwrapFormAsyncValidateOrFn<TOnBlurAsync>
| UnwrapFormValidateOrFn<TOnSubmit>
| UnwrapFormAsyncValidateOrFn<TOnSubmitAsync>
| UnwrapFormAsyncValidateOrFn<TOnServer>)[];
getFieldInfo<TField>(field): FieldInfo<TFormData>
getFieldInfo<TField>(field): FieldInfo<TFormData>
Defined in: packages/form-core/src/FormApi.ts:1691
Gets the field info of the specified field.
• TField extends string
TField
FieldInfo<TFormData>
getFieldMeta<TField>(field): undefined | AnyFieldMeta
getFieldMeta<TField>(field): undefined | AnyFieldMeta
Defined in: packages/form-core/src/FormApi.ts:1682
Gets the metadata of the specified field.
• TField extends string
TField
undefined | AnyFieldMeta
getFieldValue<TField>(field): DeepValue<TFormData, TField>
getFieldValue<TField>(field): DeepValue<TFormData, TField>
Defined in: packages/form-core/src/FormApi.ts:1675
Gets the value of the specified field.
• TField extends string
TField
DeepValue<TFormData, TField>
handleSubmit(): Promise<void>
handleSubmit(): Promise<void>
Defined in: packages/form-core/src/FormApi.ts:1592
Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks.
Promise<void>
handleSubmit(submitMeta): Promise<void>
handleSubmit(submitMeta): Promise<void>
Defined in: packages/form-core/src/FormApi.ts:1593
Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks.
TSubmitMeta
Promise<void>
insertFieldValue<TField>(
field,
index,
value,
opts?): Promise<void>
insertFieldValue<TField>(
field,
index,
value,
opts?): Promise<void>
Defined in: packages/form-core/src/FormApi.ts:1816
• TField extends string
TField
number
DeepValue<TFormData, TField> extends any[] ? DeepValue<DeepValue<TFormData, TField>>[number] : never
UpdateMetaOptions
Promise<void>
mount(): () => void
mount(): () => void
Defined in: packages/form-core/src/FormApi.ts:1060
Function
void
moveFieldValues<TField>(
field,
index1,
index2,
opts?): void
moveFieldValues<TField>(
field,
index1,
index2,
opts?): void
Defined in: packages/form-core/src/FormApi.ts:1940
Moves the value at the first specified index to the second specified index within an array field.
• TField extends string
TField
number
number
UpdateMetaOptions
void
pushFieldValue<TField>(
field,
value,
opts?): void
pushFieldValue<TField>(
field,
value,
opts?): void
Defined in: packages/form-core/src/FormApi.ts:1801
Pushes a value into an array field.
• TField extends string
TField
DeepValue<TFormData, TField> extends any[] ? DeepValue<DeepValue<TFormData, TField>>[number] : never
UpdateMetaOptions
void
removeFieldValue<TField>(
field,
index,
opts?): Promise<void>
removeFieldValue<TField>(
field,
index,
opts?): Promise<void>
Defined in: packages/form-core/src/FormApi.ts:1874
Removes a value from an array field at the specified index.
• TField extends string
TField
number
UpdateMetaOptions
Promise<void>
replaceFieldValue<TField>(
field,
index,
value,
opts?): Promise<void>
replaceFieldValue<TField>(
field,
index,
value,
opts?): Promise<void>
Defined in: packages/form-core/src/FormApi.ts:1848
Replaces a value into an array field at the specified index.
• TField extends string
TField
number
DeepValue<TFormData, TField> extends any[] ? DeepValue<DeepValue<TFormData, TField>>[number] : never
UpdateMetaOptions
Promise<void>
reset(values?, opts?): void
reset(values?, opts?): void
Defined in: packages/form-core/src/FormApi.ts:1145
Resets the form state to the default values. If values are provided, the form will be reset to those values instead and the default values will be updated.
TFormData
Optional values to reset the form to.
Optional options to control the reset behavior.
boolean
void
resetField<TField>(field): void
resetField<TField>(field): void
Defined in: packages/form-core/src/FormApi.ts:1968
Resets the field value and meta to default state
• TField extends string
TField
void
resetFieldMeta<TField>(fieldMeta): Record<TField, AnyFieldMeta>
resetFieldMeta<TField>(fieldMeta): Record<TField, AnyFieldMeta>
Defined in: packages/form-core/src/FormApi.ts:1731
resets every field's meta
• TField extends string
Record<TField, AnyFieldMeta>
Record<TField, AnyFieldMeta>
setErrorMap(errorMap): void
setErrorMap(errorMap): void
Defined in: packages/form-core/src/FormApi.ts:1989
Updates the form's errorMap
ValidationErrorMap<TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync>
void
setFieldMeta<TField>(field, updater): void
setFieldMeta<TField>(field, updater): void
Defined in: packages/form-core/src/FormApi.ts:1710
Updates the metadata of the specified field.
• TField extends string
TField
void
setFieldValue<TField>(
field,
updater,
opts?): void
setFieldValue<TField>(
field,
updater,
opts?): void
Defined in: packages/form-core/src/FormApi.ts:1747
Sets the value of the specified field and optionally updates the touched state.
• TField extends string
TField
Updater<DeepValue<TFormData, TField>>
UpdateMetaOptions
void
swapFieldValues<TField>(
field,
index1,
index2,
opts?): void
swapFieldValues<TField>(
field,
index1,
index2,
opts?): void
Defined in: packages/form-core/src/FormApi.ts:1911
Swaps the values at the specified indices within an array field.
• TField extends string
TField
number
number
UpdateMetaOptions
void
update(options?): void
update(options?): void
Defined in: packages/form-core/src/FormApi.ts:1077
Updates the form options and form state.
FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnServer, TSubmitMeta>
void
validateAllFields(cause): Promise<unknown[]>
validateAllFields(cause): Promise<unknown[]>
Defined in: packages/form-core/src/FormApi.ts:1171
Validates all fields using the correct handlers for a given validation cause.
ValidationCause
Promise<unknown[]>
validateArrayFieldsStartingFrom<TField>(
field,
index,
cause): Promise<unknown[]>
validateArrayFieldsStartingFrom<TField>(
field,
index,
cause): Promise<unknown[]>
Defined in: packages/form-core/src/FormApi.ts:1201
Validates the children of a specified array in the form starting from a given index until the end using the correct handlers for a given validation type.
• TField extends string
TField
number
ValidationCause
Promise<unknown[]>
validateField<TField>(field, cause): unknown[] | Promise<unknown[]>
validateField<TField>(field, cause): unknown[] | Promise<unknown[]>
Defined in: packages/form-core/src/FormApi.ts:1240
Validates a specified field in the form using the correct handlers for a given validation type.
• TField extends string
TField
ValidationCause
unknown[] | Promise<unknown[]>
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.