Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tanstack/form/llms.txt
Use this file to discover all available pages before exploring further.
FieldApi
TheFieldApi class provides methods to interact with individual form fields, including getting and setting values, managing metadata, and performing validation.
Constructor
Configuration options for the field. See FieldOptions for details.
A new FieldApi instance
Example
Properties
form
name
options
state
Methods
mount()
Mounts the field instance to the form. Returns a cleanup function.A function to call when unmounting the field
Example
update()
Updates the field instance with new options.New options to apply to the field
getValue()
Gets the current field value.The current value of the field
setValue()
Sets the field value and runs the change validator.A value or function that returns the new value
If true, does not update field metadata
If true, does not trigger validation
If true, does not run field listeners
Example
getMeta()
Gets the field metadata.The field metadata including errors, touched state, validation status, etc.
Example
setMeta()
Sets the field metadata.A value or function that returns the new metadata
Example
getInfo()
Gets the field information object.The field information object containing the field instance and validation metadata
validate()
Validates the field value.The cause of the validation
If true, skips form-level validation for this field
Array of validation errors (if any)
Example
handleChange()
Handles the change event for the field.A value or function that returns the new value
Example
handleBlur()
Handles the blur event for the field.Example
Array Field Methods
The FieldApi provides methods for working with array values:pushValue()
Pushes a new value to the array field.The value to push
Options to control metadata updates, validation, and listeners
insertValue()
Inserts a value at the specified index.The index to insert at
The value to insert
replaceValue()
Replaces a value at the specified index.The index to replace
The new value
removeValue()
Removes a value at the specified index.The index to remove
swapValues()
Swaps the values at two indices.The first index
The second index
moveValue()
Moves a value from one index to another.The source index
The destination index
clearValues()
Clears all values from the array.Example: Working with Array Fields
setErrorMap()
Updates the field’s error map.The new error map to set
Example
parseValueWithSchema()
Parses the field’s value with a given schema and returns issues (if any). This method does NOT set any internal errors.The standard schema to parse this field’s value with
Array of schema validation issues (if any)
parseValueWithSchemaAsync()
Async version of parseValueWithSchema.The standard schema to parse this field’s value with
Promise resolving to array of schema validation issues (if any)
Type Parameters
The TypeScript type of the parent form data
The field name type (supports dot notation)
The TypeScript type of the field value
Type of the onMount validator
Type of the onChange validator
Type of the onChangeAsync validator
Type of the onBlur validator
Type of the onBlurAsync validator
Type of the onSubmit validator
Type of the onSubmitAsync validator
See Also
- FormApi - API for managing the entire form
- FieldOptions - Configuration options for fields
- Validators - Validation functions and types