@@ -5,7 +5,7 @@ title: FormApi
5
5
6
6
# Class: FormApi\< TFormData, TFormValidator\>
7
7
8
- Defined in: [ packages/form-core/src/FormApi.ts:361 ] ( https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L361 )
8
+ Defined in: [ packages/form-core/src/FormApi.ts:362 ] ( https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L362 )
9
9
10
10
A class representing the Form API. It handles the logic and interactions with the form state.
11
11
@@ -27,7 +27,7 @@ However, if you need to create a new instance manually, you can do so by calling
27
27
new FormApi <TFormData , TFormValidator >(opts ? ): FormApi < TFormData , TFormValidator >
28
28
` ` `
29
29
30
- Defined in: [packages/form-core/src/FormApi.ts:390 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L390 )
30
+ Defined in: [packages/form-core/src/FormApi.ts:391 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L391 )
31
31
32
32
Constructs a new ` FormApi ` instance with the given form options.
33
33
@@ -49,7 +49,7 @@ Constructs a new `FormApi` instance with the given form options.
49
49
baseStore : Store < BaseFormState < TFormData > , (cb ) => BaseFormState < TFormData >> ;
50
50
` ` `
51
51
52
- Defined in: [packages/form-core/src/FormApi.ts:369 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L369 )
52
+ Defined in: [packages/form-core/src/FormApi.ts:370 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L370 )
53
53
54
54
***
55
55
@@ -59,7 +59,7 @@ Defined in: [packages/form-core/src/FormApi.ts:369](https://github.com/TanStack/
59
59
fieldInfo : Record < unknown extends TFormData ? string : TFormData extends readonly any [] & IsTuple < TFormData > ? PrefixTupleAccessor < TFormData < TFormData > , AllowedIndexes < TFormData < TFormData > , never > , []> : TFormData extends any [] ? PrefixArrayAccessor < TFormData < TFormData > , [any ]> : TFormData extends Date ? never : TFormData extends object ? PrefixObjectAccessor < TFormData < TFormData > , []> : TFormData extends string | number | bigint | boolean ? " " : never , FieldInfo < TFormData , TFormValidator >> ;
60
60
` ` `
61
61
62
- Defined in: [packages/form-core/src/FormApi.ts:375 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L375 )
62
+ Defined in: [packages/form-core/src/FormApi.ts:376 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L376 )
63
63
64
64
A record of field information for each field in the form.
65
65
@@ -71,7 +71,7 @@ A record of field information for each field in the form.
71
71
fieldMetaDerived : Derived < Record < unknown extends TFormData ? string : TFormData extends readonly any [] & IsTuple < TFormData > ? PrefixTupleAccessor < TFormData < TFormData > , AllowedIndexes < TFormData < TFormData > , never > , []> : TFormData extends any [] ? PrefixArrayAccessor < TFormData < TFormData > , [any ]> : TFormData extends Date ? never : TFormData extends object ? PrefixObjectAccessor < TFormData < TFormData > , []> : TFormData extends string | number | bigint | boolean ? " " : never , FieldMeta >> ;
72
72
` ` `
73
73
74
- Defined in: [packages/form-core/src/FormApi.ts:370 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L370 )
74
+ Defined in: [packages/form-core/src/FormApi.ts:371 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L371 )
75
75
76
76
***
77
77
@@ -81,7 +81,7 @@ Defined in: [packages/form-core/src/FormApi.ts:370](https://github.com/TanStack/
81
81
options : FormOptions < TFormData , TFormValidator > = {};
82
82
` ` `
83
83
84
- Defined in: [packages/form-core/src/FormApi.ts:368 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L368 )
84
+ Defined in: [packages/form-core/src/FormApi.ts:369 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L369 )
85
85
86
86
The options for the form.
87
87
@@ -93,7 +93,7 @@ The options for the form.
93
93
store : Derived < FormState < TFormData >> ;
94
94
` ` `
95
95
96
- Defined in: [packages/form-core/src/FormApi.ts:371 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L371 )
96
+ Defined in: [packages/form-core/src/FormApi.ts:372 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L372 )
97
97
98
98
## Accessors
99
99
@@ -105,7 +105,7 @@ Defined in: [packages/form-core/src/FormApi.ts:371](https://github.com/TanStack/
105
105
get state (): FormState < TFormData >
106
106
` ` `
107
107
108
- Defined in: [packages/form-core/src/FormApi.ts:378 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L378 )
108
+ Defined in: [packages/form-core/src/FormApi.ts:379 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L379 )
109
109
110
110
##### Returns
111
111
@@ -119,7 +119,7 @@ Defined in: [packages/form-core/src/FormApi.ts:378](https://github.com/TanStack/
119
119
deleteField <TField >(field ): void
120
120
` ` `
121
121
122
- Defined in: [packages/form-core/src/FormApi.ts:1239 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1239 )
122
+ Defined in: [packages/form-core/src/FormApi.ts:1240 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1240 )
123
123
124
124
#### Type Parameters
125
125
@@ -143,7 +143,7 @@ Defined in: [packages/form-core/src/FormApi.ts:1239](https://github.com/TanStack
143
143
getFieldInfo <TField >(field ): FieldInfo < TFormData , TFormValidator >
144
144
` ` `
145
145
146
- Defined in: [packages/form-core/src/FormApi.ts:1148 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1148 )
146
+ Defined in: [packages/form-core/src/FormApi.ts:1149 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1149 )
147
147
148
148
Gets the field info of the specified field.
149
149
@@ -169,7 +169,7 @@ Gets the field info of the specified field.
169
169
getFieldMeta <TField >(field ): undefined | FieldMeta
170
170
` ` `
171
171
172
- Defined in: [packages/form-core/src/FormApi.ts:1139 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1139 )
172
+ Defined in: [packages/form-core/src/FormApi.ts:1140 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1140 )
173
173
174
174
Gets the metadata of the specified field.
175
175
@@ -195,7 +195,7 @@ Gets the metadata of the specified field.
195
195
getFieldValue <TField >(field ): DeepValue < TFormData , TField , IsNullable < TFormData >>
196
196
` ` `
197
197
198
- Defined in: [packages/form-core/src/FormApi.ts:1132 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1132 )
198
+ Defined in: [packages/form-core/src/FormApi.ts:1133 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1133 )
199
199
200
200
Gets the value of the specified field.
201
201
@@ -221,7 +221,7 @@ Gets the value of the specified field.
221
221
handleSubmit (): Promise < void >
222
222
` ` `
223
223
224
- Defined in: [packages/form-core/src/FormApi.ts:1063 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1063 )
224
+ Defined in: [packages/form-core/src/FormApi.ts:1064 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1064 )
225
225
226
226
Handles the form submission, performs validation, and calls the appropriate onSubmit or onInvalidSubmit callbacks.
227
227
@@ -241,9 +241,7 @@ insertFieldValue<TField>(
241
241
opts ? ): Promise < void >
242
242
` ` `
243
243
244
- Defined in: [packages/form-core/src/FormApi.ts:1271](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1271)
245
-
246
- Inserts a value into an array field at the specified index, shifting the subsequent values to the right.
244
+ Defined in: [packages/form-core/src/FormApi.ts:1269](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1269)
247
245
248
246
#### Type Parameters
249
247
@@ -279,7 +277,7 @@ Inserts a value into an array field at the specified index, shifting the subsequ
279
277
mount (): () => void
280
278
` ` `
281
279
282
- Defined in: [packages/form-core/src/FormApi.ts:638 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L638 )
280
+ Defined in: [packages/form-core/src/FormApi.ts:639 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L639 )
283
281
284
282
#### Returns
285
283
@@ -301,7 +299,7 @@ moveFieldValues<TField>(
301
299
opts ? ): void
302
300
` ` `
303
301
304
- Defined in: [packages/form-core/src/FormApi.ts:1389 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1389 )
302
+ Defined in: [packages/form-core/src/FormApi.ts:1398 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1398 )
305
303
306
304
Moves the value at the first specified index to the second specified index within an array field.
307
305
@@ -342,7 +340,7 @@ pushFieldValue<TField>(
342
340
opts ? ): void
343
341
` ` `
344
342
345
- Defined in: [packages/form-core/src/FormApi.ts:1253 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1253 )
343
+ Defined in: [packages/form-core/src/FormApi.ts:1254 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1254 )
346
344
347
345
Pushes a value into an array field.
348
346
@@ -379,7 +377,7 @@ removeFieldValue<TField>(
379
377
opts ? ): Promise < void >
380
378
` ` `
381
379
382
- Defined in: [packages/form-core/src/FormApi.ts:1324 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1324 )
380
+ Defined in: [packages/form-core/src/FormApi.ts:1327 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1327 )
383
381
384
382
Removes a value from an array field at the specified index.
385
383
@@ -417,7 +415,7 @@ replaceFieldValue<TField>(
417
415
opts ? ): Promise < void >
418
416
` ` `
419
417
420
- Defined in: [packages/form-core/src/FormApi.ts:1298 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1298 )
418
+ Defined in: [packages/form-core/src/FormApi.ts:1301 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1301 )
421
419
422
420
Replaces a value into an array field at the specified index.
423
421
@@ -455,7 +453,7 @@ Replaces a value into an array field at the specified index.
455
453
reset (values ? , opts ? ): void
456
454
` ` `
457
455
458
- Defined in: [packages/form-core/src/FormApi.ts:701 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L701 )
456
+ Defined in: [packages/form-core/src/FormApi.ts:702 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L702 )
459
457
460
458
Resets the form state to the default values.
461
459
If values are provided, the form will be reset to those values instead and the default values will be updated.
@@ -488,7 +486,7 @@ Optional options to control the reset behavior.
488
486
resetFieldMeta <TField >(fieldMeta ): Record < TField , FieldMeta >
489
487
` ` `
490
488
491
- Defined in: [packages/form-core/src/FormApi.ts:1185 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1185 )
489
+ Defined in: [packages/form-core/src/FormApi.ts:1186 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1186 )
492
490
493
491
#### Type Parameters
494
492
@@ -512,7 +510,7 @@ Defined in: [packages/form-core/src/FormApi.ts:1185](https://github.com/TanStack
512
510
setErrorMap (errorMap ): void
513
511
` ` `
514
512
515
- Defined in: [packages/form-core/src/FormApi.ts:1413 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1413 )
513
+ Defined in: [packages/form-core/src/FormApi.ts:1425 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1425 )
516
514
517
515
Updates the form's errorMap
518
516
@@ -534,7 +532,7 @@ Updates the form's errorMap
534
532
setFieldMeta <TField >(field , updater ): void
535
533
` ` `
536
534
537
- Defined in: [packages/form-core/src/FormApi.ts:1167 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1167 )
535
+ Defined in: [packages/form-core/src/FormApi.ts:1168 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1168 )
538
536
539
537
Updates the metadata of the specified field.
540
538
@@ -567,7 +565,7 @@ setFieldValue<TField>(
567
565
opts ? ): void
568
566
` ` `
569
567
570
- Defined in: [packages/form-core/src/FormApi.ts:1209 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1209 )
568
+ Defined in: [packages/form-core/src/FormApi.ts:1210 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1210 )
571
569
572
570
Sets the value of the specified field and optionally updates the touched state.
573
571
@@ -605,7 +603,7 @@ swapFieldValues<TField>(
605
603
opts ? ): void
606
604
` ` `
607
605
608
- Defined in: [packages/form-core/src/FormApi.ts:1363 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1363 )
606
+ Defined in: [packages/form-core/src/FormApi.ts:1369 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1369 )
609
607
610
608
Swaps the values at the specified indices within an array field.
611
609
@@ -643,7 +641,7 @@ Swaps the values at the specified indices within an array field.
643
641
update (options ? ): void
644
642
` ` `
645
643
646
- Defined in: [packages/form-core/src/FormApi.ts:655 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L655 )
644
+ Defined in: [packages/form-core/src/FormApi.ts:656 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L656 )
647
645
648
646
Updates the form options and form state.
649
647
@@ -665,7 +663,7 @@ Updates the form options and form state.
665
663
validateAllFields (cause ): Promise < ValidationError []>
666
664
` ` `
667
665
668
- Defined in: [packages/form-core/src/FormApi.ts:727 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L727 )
666
+ Defined in: [packages/form-core/src/FormApi.ts:728 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L728 )
669
667
670
668
Validates all fields using the correct handlers for a given validation cause.
671
669
@@ -690,7 +688,7 @@ validateArrayFieldsStartingFrom<TField>(
690
688
cause ): Promise < ValidationError []>
691
689
` ` `
692
690
693
- Defined in: [packages/form-core/src/FormApi.ts:757 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L757 )
691
+ Defined in: [packages/form-core/src/FormApi.ts:758 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L758 )
694
692
695
693
Validates the children of a specified array in the form starting from a given index until the end using the correct handlers for a given validation type.
696
694
@@ -726,7 +724,7 @@ validateField<TField>(field, cause):
726
724
| Promise < ValidationError []>
727
725
` ` `
728
726
729
- Defined in: [packages/form-core/src/FormApi.ts:796 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L796 )
727
+ Defined in: [packages/form-core/src/FormApi.ts:797 ](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L797 )
730
728
731
729
Validates a specified field in the form using the correct handlers for a given validation type.
732
730
0 commit comments