final-form / final-form/react-final-form

Setting submission errors after autosaving

Open
#815 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?

I'm not sure if what I'm trying is supported so it could be either.

### What is the current behavior?

I've got a form using autosave similar to the example in the docs and I'm trying to set form errors from server side validations in the response.

https://codesandbox.io/s/react-final-form-auto-save-with-debounce-4yn90?file=/index.js is a modified version of the example from the docs that shows roughly what I'm trying to do. The First Name field has a server side validation whereas the Last Name field is validated client side. The client side validation works fine but I can't figure out how to set the server side errors in the form state.

I've tried to use a mutator to allow me to set the errors but setting the errors in the formState doesn't update the field to show the error.

### What is the expected behavior?

Using a mutator to set the error object in the form state should update the props passed to Fields so they can render errors.

### Sandbox Link

https://codesandbox.io/s/react-final-form-auto-save-with-debounce-4yn90?file=/index.js

### What's your environment?

Final Form 4.20
React Final Form 6.5.0

MacOS Version 10.15.3 (19D76)
Chrome Version 83.0.4103.106 (Official Build) (64-bit)

### Other information

If I can somehow configure handleSubmit to ignore the validations so I can use the standard method of setting errors by resolving the response to the errors object that'd also work, but I can't find any way to skip field validations when submitting.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.