question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possibility to reset form errors (_error) in redux-form 6.5.0

See original GitHub issue

Are you submitting a bug report or a feature request?

If I understood the docs correctly, this is currently not possible. Thus a feature request.

What is the current behavior?

A form error can be set in onSubmit with

throw new SubmissionError({ _error: 'My form error message.' });

When changing a value or re-submitting the form, the form error does not disappear, and there does not seem to be a way to (only) remove the form error manually (e.g. in onSubmit).

What is the expected behavior?

It should be possible to remove/reset the form error message (_error).

What’s your environment?

redux-form 6.5.0

Other informations

http://stackoverflow.com/questions/42288445/redux-form-6-5-0-how-to-clear-form-error-error

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
eaardalcommented, Feb 27, 2017

Hi. We have the same issue, but found that dispatching the stopSubmit action with an empty errors object will clear it:

import { stopSubmit } from 'redux-form';
dispatch(stopSubmit('myFormName', {}))

https://github.com/erikras/redux-form/blob/e9bcc1b54e211071f0cefc644c1ab7b2e93b9d78/src/__tests__/reducer.stopSubmit.spec.js#L291

1reaction
jamesseanwrightcommented, Sep 7, 2017

If submission is being blocked by async validation errors, then one can clear them with the stopAsyncValidation action creator:

dispatch(stopAsyncValidation(FORM_NAME, { clear: true }));

Why the clear property? The reducer branch for the STOP_ASYNC_VALIDATION action will only clear errors associated with a form if the payload has at least one key. It would be great if this behaviour could be changed in a backwards-compatible manner, but admittedly the codebase on which I’m currently working uses async validation for cases in which submission validation would be more appropriate; I have no idea why…

Read more comments on GitHub >

github_iconTop Results From Across the Web

redux-form (6.5.0): How to clear form error (_error)?
It is easy to set a form error in onSubmit with throw new SubmissionError({ _error: 'My form error message.' });.
Read more >
Synchronous Validation Example - Redux Form
IMPORTANT: Synchronous validation happens on every change to your form data, so, if your field value is invalid, your field.error value will always...
Read more >
A practical guide to Redux Form - ERIK RASMUSSEN
Forms are hard in any framework, but they are extra complicated in React due to the recommended method of using "controlled inputs", ...
Read more >
redux-form/stats.json - UNPKG
The CDN for redux-form. ... Users/erik/oss/redux-form/src/FieldArray.js", ... environment ' +\n 'for the full error message and additional helpful warnings.
Read more >
simpler-redux-form - npm Package Health Analysis - Snyk
value - the initial value of the field. validate(value, allFormValues) : String — form field value validation function returning an error ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found