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

FieldApi.md

346 lines6.1 KB

1---
2id: FieldApi
3title: FieldApi
4---
5​
6Defined in: [FieldApi/FieldApi.public.ts:123](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L123)
7​
8## Type Parameters
9​
10### TFieldName
11​
12`TFieldName`
13​
14### TFieldValue
15​
16`TFieldValue`
17​
18### TFieldError
19​
20`TFieldError`
21​
22### TFormData
23​
24`TFormData`
25​
26### TFormErrorTypes
27​
28`TFormErrorTypes` *extends* [`FormErrorTypes`](FormErrorTypes.md)
29​
30## Properties
31​
32### atom
33​
34```ts
35atom: ReadonlyAtom<FieldState<TFieldValue, TFieldError>>;
36```
37​
38Defined in: [FieldApi/FieldApi.public.ts:206](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L206)
39​
40***
41​
42### clearValues
43​
44```ts
45clearValues: FieldClearValuesFn;
46```
47​
48Defined in: [FieldApi/FieldApi.public.ts:179](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L179)
49​
50Clear all values from this field's array.
51If this field is not an array, this method will be ignored.
52​
53#### Param
54​
55**options**
56​
57Optional update options
58​
59***
60​
61### errors
62​
63```ts
64errors: FieldErrors<TFieldError>;
65```
66​
67Defined in: [FieldApi/FieldApi.public.ts:212](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L212)
68​
69***
70​
71### filterValues
72​
73```ts
74filterValues: FieldFilterValuesFn<TFieldValue>;
75```
76​
77Defined in: [FieldApi/FieldApi.public.ts:204](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L204)
78​
79Filter the values in this field's array using a predicate function.
80If this field is not an array, this method will be ignored.
81​
82#### Param
83​
84**predicate**
85​
86The predicate function to filter values. Returns true to keep the value, false to remove it.
87​
88#### Param
89​
90**options**
91​
92Optional update options including a custom `thisArg` for the predicate
93​
94***
95​
96### form
97​
98```ts
99form: FormApi<TFormData, TFormErrorTypes>;
100```
101​
102Defined in: [FieldApi/FieldApi.public.ts:133](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L133)
103​
104The form that owns this field.
105​
106***
107​
108### handleBlur
109​
110```ts
111handleBlur: FieldVoidFn;
112```
113​
114Defined in: [FieldApi/FieldApi.public.ts:216](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L216)
115​
116***
117​
118### handleChange
119​
120```ts
121handleChange: FieldHandleChangeFn<TFieldValue>;
122```
123​
124Defined in: [FieldApi/FieldApi.public.ts:214](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L214)
125​
126***
127​
128### insertValue
129​
130```ts
131insertValue: FieldInsertValueFn<TFieldValue>;
132```
133​
134Defined in: [FieldApi/FieldApi.public.ts:172](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L172)
135​
136Insert a new value into this field's array at the specified index.
137If this field is not an array, this method will be ignored.
138​
139#### Param
140​
141**index**
142​
143The index at which to insert the value
144​
145#### Param
146​
147**value**
148​
149The value to insert
150​
151#### Param
152​
153**options**
154​
155Optional update options
156​
157***
158​
159### meta
160​
161```ts
162meta: FieldMeta<TFieldError>;
163```
164​
165Defined in: [FieldApi/FieldApi.public.ts:210](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L210)
166​
167***
168​
169### moveValue
170​
171```ts
172moveValue: FieldMoveValueFn;
173```
174​
175Defined in: [FieldApi/FieldApi.public.ts:155](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L155)
176​
177Move an element in this field's array from one index to another.
178If this field is not an array, this method will be ignored.
179​
180#### Param
181​
182**fromIndex**
183​
184The current index of the element to move
185​
186#### Param
187​
188**toIndex**
189​
190The index to move the element to
191​
192#### Param
193​
194**options**
195​
196Optional update options
197​
198***
199​
200### pushValue
201​
202```ts
203pushValue: FieldPushValueFn<TFieldValue>;
204```
205​
206Defined in: [FieldApi/FieldApi.public.ts:163](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L163)
207​
208Push a new value into this field's array.
209If this field is not an array, this method will be ignored.
210​
211#### Param
212​
213**value**
214​
215The value to push into the array
216​
217#### Param
218​
219**options**
220​
221Optional update options
222​
223***
224​
225### removeValue
226​
227```ts
228removeValue: FieldRemoveValueFn;
229```
230​
231Defined in: [FieldApi/FieldApi.public.ts:196](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L196)
232​
233Remove a value from this field's array at the specified index.
234If this field is not an array, this method will be ignored.
235​
236#### Param
237​
238**index**
239​
240The index of the value to remove
241​
242#### Param
243​
244**options**
245​
246Optional update options
247​
248***
249​
250### replaceValue
251​
252```ts
253replaceValue: FieldReplaceValueFn<TFieldValue>;
254```
255​
256Defined in: [FieldApi/FieldApi.public.ts:188](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L188)
257​
258Replace the value at the specified index in this field's array.
259If this field is not an array, this method will be ignored.
260​
261#### Param
262​
263**index**
264​
265The index of the value to replace
266​
267#### Param
268​
269**value**
270​
271The new value
272​
273#### Param
274​
275**options**
276​
277Optional update options
278​
279***
280​
281### reset
282​
283```ts
284reset: FieldVoidFn;
285```
286​
287Defined in: [FieldApi/FieldApi.public.ts:218](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L218)
288​
289***
290​
291### swapValues
292​
293```ts
294swapValues: (indexA, indexB) => void;
295```
296​
297Defined in: [FieldApi/FieldApi.public.ts:146](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L146)
298​
299Swap two elements in this field's array.
300If this field is not an array, this method will be ignored.
301​
302#### Parameters
303​
304##### indexA
305​
306`number`
307​
308The index of the first element to swap
309​
310##### indexB
311​
312`number`
313​
314The index of the second element to swap
315​
316#### Returns
317​
318`void`
319​
320***
321​
322### value
323​
324```ts
325value: TFieldValue;
326```
327​
328Defined in: [FieldApi/FieldApi.public.ts:208](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L208)
329​
330## Accessors
331​
332### name
333​
334#### Get Signature
335​
336```ts
337get name(): TFieldName;
338```
339​
340Defined in: [FieldApi/FieldApi.public.ts:138](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi/FieldApi.public.ts#L138)
341​
342The name of the field.
343​
344##### Returns
345​
346`TFieldName`