Capítulo 26 de 29
FormApi and FieldApi (from the framework-agnostic @tanstack/form-core) are the classes every framework adapter's useForm/useField wraps — this is the full method surface once you're past the render-prop layer.
FormApi — key properties| Property | Purpose |
|---|---|
state | Current form state (values, errors, validation status) |
store | The reactive store underlying useSelector/Subscribe (ch014) |
options | The FormOptions passed at construction (ch027) |
fieldInfo | Per-field metadata tracking, keyed by field name |
FormApi — key methods| Method | Purpose |
|---|---|
handleSubmit(submitMeta?) | Validates, then calls onSubmit/onSubmitInvalid (ch017) |
setFieldValue(field, updater, opts?) | Sets a field's value, optionally marking it touched |
getFieldValue(field) | Reads a field's current value |
getFieldMeta(field) / setFieldMeta(field, updater) | Read/write a field's metadata |
reset(values?, opts?) / resetField(field) | Reset the whole form or one field to defaults |
validateField(field, cause) / validateAllFields(cause) | Manually trigger validation |
pushFieldValue / removeFieldValue / insertFieldValue / replaceFieldValue / swapFieldValues / moveFieldValues | Array-field mutations (ch011), callable from the form level via a field name |
getAllErrors() | Combined form-level + field-level errors |
parseValuesWithSchema() | Validate against a Standard Schema without storing errors as side effects |
FieldApi — key properties/methods| Member | Purpose |
|---|---|
form | Back-reference to the owning FormApi |
state | This field's current value/meta (mirrors field.state seen in every earlier chapter) |
setValue(updater, opts?) | Update value, triggering change validation |
pushValue / removeValue / replaceValue / insertValue / swapValues / moveValue / clearValues | Array mutation methods (ch011) — the field-level counterparts of FormApi's array methods above |
validate(cause, opts?) | Trigger this field's validation directly |
parseValueWithSchema() / parseValueWithSchemaAsync() | Standard Schema validation for just this field |
mount() | Registers the field with the form; returns an unmount function |
handleChange(updater) / handleBlur() | The two event handlers every earlier chapter's examples call |
FormApi level (by field name string) and the FieldApi level (on the field instance itself, ch011) — pick whichever you already have in scope.getFieldValue/setFieldValue on FormApi are the mechanism behind cross-field reads in ch013's linked-fields pattern.parseValuesWithSchema/parseValueWithSchema(Async) let you validate against a Standard Schema without it becoming a registered validator with side effects — useful for one-off checks distinct from the field's normal validation pipeline (ch008).useForm/useField extend these same classes.