FormApi¶
class FormApi¶
Limited information from form context.
Properties
| Name | Type | Description |
|---|---|---|
dirty |
boolean |
True when any field differs from its default value. |
isValid |
boolean |
Indicates whether all current validation rules pass. |
getValues |
getValues | Returns a snapshot of all form values. |
getErrors |
getErrors | Returns a map of validation errors keyed by field name. |
getError |
getError | Returns the validation errors for the provided field. |
getValue |
getValue | Reads the current value of the provided field. |
submitForm |
submitForm | Triggers form submission using the current field values. |
validateForm |
validateForm | Runs validation for all fields and resolves with validation issues. |
resetForm |
resetForm | Resets the form values and optionally preserves default values. |
setFieldValue |
setFieldValue | Updates a single field value and meta information. |
setFieldTouched |
setFieldTouched | Marks a field as touched or untouched. |
setValues |
setValues | Replaces multiple field values at once. |
setTouched |
setTouched | Marks multiple fields as touched. |
rerenderForm |
rerenderForm | Forces the form to re-render without changing state. |
function getError¶
Returns the validation errors for the provided field.
Returns
- unknown
Parameters
| Name | Type | Description |
|---|---|---|
fieldName |
string |
function getErrors¶
Returns a map of validation errors keyed by field name.
Returns
- unknown
function getValue¶
Reads the current value of the provided field.
Returns
- unknown
Parameters
| Name | Type | Description |
|---|---|---|
fieldName |
string |
function getValues¶
Returns a snapshot of all form values.
Returns
- unknown
function rerenderForm¶
Forces the form to re-render without changing state.
Returns
- void
function resetForm¶
Resets the form values and optionally preserves default values.
Returns
- void
Parameters
| Name | Type | Description |
|---|---|---|
values |
unknown |
|
opts |
{ keepDefaultValues?: boolean } |
function setFieldTouched¶
Marks a field as touched or untouched.
Returns
- void
Parameters
| Name | Type | Description |
|---|---|---|
fieldName |
string |
|
touched |
boolean |
function setFieldValue¶
Updates a single field value and meta information.
Returns
- void
Parameters
| Name | Type | Description |
|---|---|---|
fieldName |
string |
|
value |
unknown |
function setTouched¶
Marks multiple fields as touched.
Returns
- void
Parameters
| Name | Type | Description |
|---|---|---|
touchedFields |
string[] |
function setValues¶
Replaces multiple field values at once.
Returns
- void
Parameters
| Name | Type | Description |
|---|---|---|
newValues |
Record<string, any> |
function submitForm¶
Triggers form submission using the current field values.
Returns
- Promise<void>
function validateForm¶
Runs validation for all fields and resolves with validation issues.
Returns
- Promise<unknown[]>
Parameters
| Name | Type | Description |
|---|---|---|
cause |
"change"|"blur"|"submit"|"mount"|"server"|"dynamic" |