Open History to see the last commit
1---
2id: FormSubmitContext
3title: FormSubmitContext
4---
5β
6Defined in: [FormApi/FormApi.public.ts:105](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L105)
7β
8Context passed to `onSubmit` after submission validation succeeds.
9β
10## Example
11β
12```ts
13{
14 // ...
15 onSubmit: async ({ value, createValidationError }) => {
16 const result = await saveUser(value)
17β
18 if (!result.ok) {
19 return createValidationError(result.error)
20 }
21 },
22}
23```
24β
25## Type Parameters
26β
27### TFormData
28β
29`TFormData`
30β
31Library-managed. Do not specify explicitly.
32β
33### TOutputs
34β
35`TOutputs`
36β
37Library-managed. Do not specify explicitly.
38β
39### TFormErrorTypes
40β
41`TFormErrorTypes` *extends* [`FormErrorTypes`](FormErrorTypes.md)
42β
43Library-managed. Do not specify explicitly.
44β
45## Properties
46β
47### createErrorMap
48β
49```ts
50createErrorMap: CreateSubmitErrorMapFn<TFormData>;
51```
52β
53Defined in: [FormApi/FormApi.public.ts:155](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L155)
54β
55***
56β
57### createValidationError
58β
59```ts
60createValidationError: CreateValidationErrorFn<TFormData>;
61```
62β
63Defined in: [FormApi/FormApi.public.ts:154](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L154)
64β
65Creates a validation error that can be returned from `onSubmit`.
66β
67Return the created error from `onSubmit` to add its form- and field-level
68errors to validation state.
69β
70#### Example
71β
72```ts
73{
74 // ...
75 onSubmit: async ({ value, createValidationError }) => {
76 const result = await saveUser(value)
77β
78 if (result.status === 409) {
79 return createValidationError({
80 form: 'A user with this email already exists',
81 fields: {},
82 })
83 }
84 },
85}
86```
87β
88***
89β
90### formApi
91β
92```ts
93formApi: FormApi<TFormData, TFormErrorTypes>;
94```
95β
96Defined in: [FormApi/FormApi.public.ts:113](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L113)
97β
98The form API handling this submission.
99β
100***
101β
102### parseIssues
103β
104```ts
105parseIssues: ParseSubmitIssuesFn<TFormData>;
106```
107β
108Defined in: [FormApi/FormApi.public.ts:176](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L176)
109β
110Parses Standard Schema issues into an error returnable from `onSubmit`.
111β
112Issue paths are mapped to fields in the submitted value. Return the parsed
113error from `onSubmit` to add those errors to validation state.
114β
115#### Example
116β
117```ts
118{
119 // ...
120 onSubmit: async ({ value, parseIssues }) => {
121 const result = zodSchema.safeParse(value)
122β
123 if (!result.success) {
124 return parseIssues(result.error.issues)
125 }
126 },
127}
128```
129β
130***
131β
132### validatorOutputs
133β
134```ts
135validatorOutputs: TOutputs;
136```
137β
138Defined in: [FormApi/FormApi.public.ts:130](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L130)
139β
140Schema outputs and `createOutput` payloads from this submission, ordered by
141validator index. Skipped validators and successful returns without an output
142contribute `undefined`.
143β
144#### Example
145β
146```ts
147{
148 // ...
149 onSubmit: async ({ validatorOutputs }) => {
150 const validatedUser = validatorOutputs[0]
151 await saveUser(validatedUser)
152 },
153}
154```
155β
156***
157β
158### value
159β
160```ts
161value: TFormData;
162```
163β
164Defined in: [FormApi/FormApi.public.ts:111](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi/FormApi.public.ts#L111)
165β
166The form values for this submission.