final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

Field level submission errors are not propagated to meta.submissionError #329

Open kirstu opened 6 years ago

kirstu commented 6 years ago

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

Submission errors to "deep" fields do not propagate to field level meta.submissionError prop. I.e. if one would have a form with state of

{
  'profile.userName': 'Aasd',
}

and submitting this data would result in the following error object from submit function:

{
  'profile.userName': 'This value wont do',
}

The above error will not show up in the field for profile.userName.

See sandbox for reproduction: https://codesandbox.io/s/0o9lmozrmv

What is the expected behavior?

The field meta should have submissionError set to 'This value wont do'.

Sandbox Link

https://codesandbox.io/s/0o9lmozrmv

What's your environment?

"react-final-form": "^3.6.5" "final-form": "^4.9.1"

Other information

jkarwasz-wuwit commented 6 years ago

The error object has to have the same structure as the form data.

In your example: { 'profile': { 'userName': 'This value wont do' } } Should work fine.

Does this help?

levino commented 5 years ago

Should be closed.