Describe the bug#
If fieldMeta doesn't exist when an async validator runs, it won't be created. (synchronous validators do cause the meta to get created).
If the meta already exists (because you have a form.Field for that field, or because you do something like setFieldValue('age', 2)), the error gets added to the fieldMeta without a problem.
Your minimal, reproducible example#
https://stackblitz.com/edit/tanstack-form-vxfykhc5?file=src%2Findex.tsx,package.json
Steps to reproduce#
- Submit the form without clicking anything else.
form.errors shows errors at the form level, but "Age Meta" remains empty
- Change
onSubmitAsync to onSubmit, then submit the form. The meta gets created as expected.
Expected behavior#
If errors happen when doing an async validation, the field meta should be created if necessary.
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
macOS
Safari
TanStack Form adapter#
react-form
TanStack Form version#
1.28.0
TypeScript version#
No response
Additional context#
Possibly related to #1460
This issue is a pretty big priority for us because of the way a few things interact:
useFormContextto get/set value and state on fields that do not have aform.AppFieldmounted. I have found that, besides this issues, fieldMeta is the most reliable way to get the error state of fields.So I made a PR with a proposed fix for this.