TanStack
API Reference

FormApi

Interface: FormApi<TFormData, TFormErrorTypes>

Defined in: FormApi/FormApi.public.ts:304

Extends

Type Parameters

TFormData

TFormData

TFormErrorTypes

TFormErrorTypes extends FormErrorTypes

Properties

atom

ts
atom: ReadonlyAtom<FormState<TFormData, TFormErrorTypes>>;

Defined in: FormApi/FormApi.public.ts:309


clearFieldValues

ts
clearFieldValues: ClearFieldValuesFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:134

Clear all values from an array field. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Inherited from

FormApiArrayMethods.clearFieldValues


defaultValues

ts
readonly defaultValues: TFormData;

Defined in: FormApi/FormApi.public.ts:312

The current baseline values used by reset() and isDefaultValue.


filterFieldValues

ts
filterFieldValues: FilterFieldValuesFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:152

Filter the values in an array field using a predicate function. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

predicate

The predicate function to filter values. Returns true to keep the value, false to remove it.

Param

options

Optional update options including a custom thisArg for the predicate

Inherited from

FormApiArrayMethods.filterFieldValues


formId

ts
readonly formId: string;

Defined in: FormApi/FormApi.public.ts:313


getFieldValue

ts
getFieldValue: GetFieldValueFn<TFormData>;

Defined in: FormApi/FormApiFieldMethods.types.public.ts:37

TODO

Param

DeepKeys

Returns

Inherited from

FormApiFieldMethods.getFieldValue


handleSubmit

ts
handleSubmit: () => Promise<FormValidationError<TFormData>[]>;

Defined in: FormApi/FormApi.public.ts:330

TODO for later: submit meta

Returns

Promise<FormValidationError<TFormData>[]>


insertFieldValue

ts
insertFieldValue: InsertFieldValueFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:127

Insert a value into an array field at the specified index. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

index

The index at which to insert the value

Param

value

The value to insert

Param

options

Optional update options

Inherited from

FormApiArrayMethods.insertFieldValue


moveFieldValue

ts
moveFieldValue: MoveFieldValueFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:108

Move a value in an array field from one index to another. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

fromIndex

The current index of the value to move

Param

toIndex

The index to move the value to

Param

options

Optional update options

Inherited from

FormApiArrayMethods.moveFieldValue


pushFieldValue

ts
pushFieldValue: PushFieldValueFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:117

Push a value into an array field. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

value

The value to push

Param

options

Optional update options

Inherited from

FormApiArrayMethods.pushFieldValue


removeFieldValue

ts
removeFieldValue: RemoveFieldValueFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:143

Remove a value from an array field at the specified index. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

index

The index of the value to remove

Param

options

Optional update options

Inherited from

FormApiArrayMethods.removeFieldValue


reset

ts
reset: (values?, opts?) => void;

Defined in: FormApi/FormApi.public.ts:342

Reset form values, metadata, validation state, and mounted fields.

reset() restores the current defaultValues.

reset(values) sets the current values and also updates defaultValues to those values.

reset(values, { updateDefaultValues: false }) sets the current values while preserving the previous defaultValues baseline.

Parameters

values?

TFormData

opts?

FormResetOptions

Returns

void


resetField

ts
resetField: ResetFieldFn<TFormData>;

Defined in: FormApi/FormApiFieldMethods.types.public.ts:39

Inherited from

FormApiFieldMethods.resetField


setFieldValue

ts
setFieldValue: SetFieldValueFn<TFormData>;

Defined in: FormApi/FormApiFieldMethods.types.public.ts:30

TODO

Param

DeepKeys

Param

updater

Inherited from

FormApiFieldMethods.setFieldValue


state

ts
readonly state: FormState<TFormData, TFormErrorTypes>;

Defined in: FormApi/FormApi.public.ts:310


swapFieldValues

ts
swapFieldValues: SwapFieldValuesFn<TFormData>;

Defined in: FormApi/FormApiArrayMethods.types.public.ts:98

Swap two values in an array field. If the field is not an array, this method will be ignored.

Param

arrayFieldName

The name of the array field

Param

indexA

The index of the first value to swap

Param

indexB

The index of the second value to swap

Inherited from

FormApiArrayMethods.swapFieldValues


validate

ts
validate: (signal) => Promise<FormValidationError<TFormData>[]>;

Defined in: FormApi/FormApi.public.ts:322

TODO expand on it

Validates with the given validation signal and returns errors if they appeared. It will automatically populate the form's error state.

Parameters

signal

ConfigurableValidationTrigger

Returns

Promise<FormValidationError<TFormData>[]>