Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

FormApiFieldMethods.md

94 lines2.2 KB

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

Type-safe methods for reading, updating, and resetting individual field values.

Extended by

Type Parameters

TFormData

TFormData

Library-managed. Do not specify explicitly.

Properties

getFieldValue

getFieldValue: GetFieldValueFn<TFormData>;

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

Reads the current value at a field path.

This is a read-only operation and does not create a FieldApi for the path.

Example

const name = formApi.getFieldValue('profile.name')

Returns

The current value at the path, or undefined when the path cannot be resolved at runtime.


resetField

resetField: ResetFieldFn<TFormData>;

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

Restores a field path from defaultValues and resets state for its field subtree.

Existing FieldApi instances at or below the path remain mounted. Form-wide dirty history remains unchanged; use formApi.reset() to clear it.

Example

formApi.setFieldValue('profile.name', 'Grace')
formApi.resetField('profile.name')
// `profile.name` is restored from `defaultValues`.

setFieldValue

setFieldValue: SetFieldValueFn<TFormData>;

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

Updates the current value at a field path.

The next value may be supplied directly or calculated from the current value. By default, the update marks the field as touched and dirty, notifies change listeners, and runs change validation.

Example

formApi.setFieldValue('profile.name', 'Ada')
formApi.setFieldValue('visitCount', (count) => count + 1)