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

TanStackFormController.md

153 lines3.4 KB

1---
2id: TanStackFormController
3title: TanStackFormController
4---
5​
6# Class: TanStackFormController\<TParentData, TFormValidator\>
7​
8## Type Parameters
9​
10β€’ **TParentData**
11​
12β€’ **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined`
13​
14## Implements
15​
16- `ReactiveController`
17​
18## Constructors
19​
20### new TanStackFormController()
21​
22```ts
23new TanStackFormController<TParentData, TFormValidator>(host, config?): TanStackFormController<TParentData, TFormValidator>
24```
25​
26#### Parameters
27​
28β€’ **host**: `ReactiveControllerHost`
29​
30β€’ **config?**: `FormOptions`\<`TParentData`, `TFormValidator`\>
31​
32#### Returns
33​
34[`TanStackFormController`](TanStackFormController.md)\<`TParentData`, `TFormValidator`\>
35​
36#### Defined in
37​
38[tanstack-form-controller.ts:93](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/lit-form/src/tanstack-form-controller.ts#L93)
39​
40## Properties
41​
42### api
43​
44```ts
45api: FormApi<TParentData, TFormValidator>;
46```
47​
48#### Defined in
49​
50[tanstack-form-controller.ts:91](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/lit-form/src/tanstack-form-controller.ts#L91)
51​
52## Methods
53​
54### field()
55​
56```ts
57field<TName, TFieldValidator, TData>(fieldConfig, render): object
58```
59​
60#### Type Parameters
61​
62β€’ **TName** *extends* `string` \| `number`
63​
64β€’ **TFieldValidator** *extends* `undefined` \| `Validator`\<`DeepValue`\<`TParentData`, `TName`, `IsNullable`\<`TParentData`\>\>, `unknown`\> = `undefined`
65​
66β€’ **TData** = `DeepValue`\<`TParentData`, `TName`, `IsNullable`\<`TParentData`\>\>
67​
68#### Parameters
69​
70β€’ **fieldConfig**: `FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
71​
72β€’ **render**: `renderCallback`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
73​
74#### Returns
75​
76`object`
77​
78##### values
79​
80```ts
81values: object;
82```
83​
84##### values.form
85​
86```ts
87form: FormApi<TParentData, TFormValidator>;
88```
89​
90##### values.options
91​
92```ts
93options: FieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>;
94```
95​
96##### values.render
97​
98```ts
99render: renderCallback<TParentData, TName, TFieldValidator, TFormValidator, TData>;
100```
101​
102#### Defined in
103​
104[tanstack-form-controller.ts:112](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/lit-form/src/tanstack-form-controller.ts#L112)
105​
106***
107​
108### hostConnected()
109​
110```ts
111hostConnected(): void
112```
113​
114Called when the host is connected to the component tree. For custom
115element hosts, this corresponds to the `connectedCallback()` lifecycle,
116which is only called when the component is connected to the document.
117​
118#### Returns
119​
120`void`
121​
122#### Implementation of
123​
124`ReactiveController.hostConnected`
125​
126#### Defined in
127​
128[tanstack-form-controller.ts:102](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/lit-form/src/tanstack-form-controller.ts#L102)
129​
130***
131​
132### hostDisconnected()
133​
134```ts
135hostDisconnected(): void
136```
137​
138Called when the host is disconnected from the component tree. For custom
139element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
140which is called the host or an ancestor component is disconnected from the
141document.
142​
143#### Returns
144​
145`void`
146​
147#### Implementation of
148​
149`ReactiveController.hostDisconnected`
150​
151#### Defined in
152​
153[tanstack-form-controller.ts:108](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/lit-form/src/tanstack-form-controller.ts#L108)