Skip to content

fieldMeta not set by async validator #2033

@literalpie

Description

@literalpie

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

  1. Submit the form without clicking anything else. form.errors shows errors at the form level, but "Age Meta" remains empty
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions