如何在 ReduxForm 中手动重新触发验证? [英] How to re-trigger validations manually in ReduxForm?
问题描述
我喜欢在表单安装后重新触发验证.假设我喜欢在每次单击名为验证输入"的按钮时运行验证.
I like to re-trigger validations after the form has mounted. Let's assume I like to run the validations each time I click a button named 'validate inputs'.
如何做到这一点?
相关问题:
推荐答案
手动 redux-form 验证是一个 oft 请求 功能,目前似乎没有提供.
Manual redux-form validation is an oft requested feature, that does not seem to be provided at the moment.
我个人的解决方法是在 reduxForm
包装的组件中触发 this.props.change('_validationHack', Date.now())
,然后删除 values
发送到服务器之前,在 onSubmit
方法中使用 >values._validationHack.
My personal workaround is to trigger this.props.change('_validationHack', Date.now())
in the reduxForm
-wrapped component and then remove values._validationHack
in the onSubmit
method before sending the values
to the server.
它不漂亮,但似乎无一例外.
It's not pretty, but seems to work without exception.
这篇关于如何在 ReduxForm 中手动重新触发验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!