T
TanStack6mo ago
dependent-tan

server validation error not appear in field.meta.errors

Hi, may I know how I can retrieve the field's errors when using server-side validation, seems the errors from server validation do not exist in field.state.meta.errors but only in form.state.errors
3 Replies
correct-apricot
correct-apricot6mo ago
Right now, there is no support for showing errors with individual fields, though there will be soon!
correct-apricot
correct-apricot6mo ago
Related issue you might wanna look at: https://github.com/TanStack/form/issues/1260
GitHub
FieldAPI: state.meta.errors are not updating properly when using se...
Describe the bug Basically, the field.state.meta.errors (field as AnyFieldApi) is not properly set (i.e. differs from form.store.state.errors) when using transformation to properly handle server-si...
dependent-tan
dependent-tanOP6mo ago
got it, btw what is the recommended way to show the root/global error for the form server action? I tried to return this from the server but then the error got stuck there and no way to submit the form again
return {
errorMap: {},
errors: ["Failed to submit"],
values: formData,
} satisfies ServerFormState<unknown, any>;
return {
errorMap: {},
errors: ["Failed to submit"],
values: formData,
} satisfies ServerFormState<unknown, any>;
seemsworks properly if I also provide the errorMap for onServer
return {
errorMap: { onServer: "Failed to submit" },
errors: ["Failed to submit"],
values: data,
} satisfies ServerFormState<unknown, any>;
return {
errorMap: { onServer: "Failed to submit" },
errors: ["Failed to submit"],
values: data,
} satisfies ServerFormState<unknown, any>;

Did you find this page helpful?