Display validation errors onSubmit with redux-form, and clear errors until next onSubmit on touch

淺唱寂寞╮ 提交于 2019-12-11 02:02:22

问题


I am using redux-form v6.0.1.

Right now, my use-case involves creating a form where:

  1. Errors are only displayed onSubmit, when submitFailed prop is true.
  2. When the user goes back to fix the errors, the errors go away, and don't redisplay until the next time onSubmit is called.

My current solution involves setting touchOnBlur: false, and having my error message display when touched && error. redux-form touches every field when onSubmit is triggered, so I add logic to every field to set touched = false when the user revisits, to hide the error until the next form submission. However, this seems very counter-intuitive (setting touched to false when the user touches things). Is there a more natural way to accomplish this?


回答1:


The default behavior is to clear the form-wide submit error when a field is changed. But this can be overridden by the persistentSubmitErrors config flag introduced in v6.0.4.



来源:https://stackoverflow.com/questions/39235203/display-validation-errors-onsubmit-with-redux-form-and-clear-errors-until-next

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!