New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
表单组件能否实现检验但不触发 Form.Item 的显示警告信息? #32045
Comments
警告信息不需要直接传入一个 |
琢磨了一下,需要定制 Form 组件维护一个全局状态 showMessages,然后 Form.Item 根据 showMessages 重写 rules 的 messages?正常的校验还要做的。这还只是想了一个大概,感觉复杂度有点高啊 😂 而且复杂表单的话这个方案感觉做不了。 |
通过 ConfigProvider 来配置需要的 message template,然后包一个自己的 Form 组件就行了哈 |
甚至看了一下 ConfigProvider 的源码,还是没有理解要怎么操作啊,没找到 message template 的配置 _(:3J∠)_ |
@zombieJ 这个对 validator rule 也有效吗?感觉只是对于内置的类型校验规则有效。 |
validate rule 可以自行按需返回 message,你可以做成受控的遇到提交时让校验规则返回真实的错误描述。 |
这样不就需要一个顶层状态来管理了吗?和我之前说的那个方案好像没什么本质上的区别。如果内部支持会很复杂吗? |
What problem does this feature solve?
业务需要规则校验通过提交按钮才可点击,现在暂时通过 isFieldsTouched 和 getFieldsError 组件来临时解决。
如果调用 validateFields 传入一个是否显示警告信息的配置就能完美解决了,不知道能否考虑?
What does the proposed API look like?
type ValidateFields<Values = any> = (nameList?: NamePath[], showMessages?: boolean) => Promise<Values>;
The text was updated successfully, but these errors were encountered: