-
-
Notifications
You must be signed in to change notification settings - Fork 47k
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
自定义表单的验证信息不再页面显示,却在控制台显示 #10718
Comments
Translation of this issue: Custom form verification information is no longer displayed on the page but is displayed on the console
Version3.5.1 EnvironmentWindows10, using typescript, the following link is a similar question to look for Reproduction link[https://github.com//issues/5263] (#5263) Steps to reproduce1, in the modal box embedded Form form, for the form of input required to verify the fill can click on the modal confirmation button to trigger verification What is expected?Non-conforming information is displayed on the page when customizing the verification What is actually happening?Not displayed in the page but displayed in the console 1, the use of Form.create () package modal Const WrappedPermissionModal = Form.create()(PermissionModal); 2, custom validator |
Hello @oNexiaoyao. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro. Issues labeled by |
This issue is closed because it has been marked as |
请教一下,这个问题是如何解决的? 在modal框中嵌入Form表单,对form做必填项验证。验证信息打印在控制台,没有显示。 |
这个问题我也遇到了,请问有解决方案吗?自定义校验在控制台显示而不是在表单下面显示 |
碰到同样的问题了,请问大家怎么解决的? |
应该是使用姿势的问题,可以参考 The demo of Modal with Form 对照下自己的写法。 |
// 这样应该就可以了
validator: (rule, value, callback) => {
if (value && value !== 'abc') {
rule.message = '输入的不是abc';
callback(true);
}
callback();
} |
validateName = async(rule, value, callback) => { 异步这样子就可以了 |
Version
3.5.1
Environment
windows10, 使用typescript,下面的链接是找的一个类似的问题
Reproduction link
#5263
Steps to reproduce
1,在modal框中嵌入Form表单,针对表单中的input的做必填项验证可以在点击modal的确认按钮触发验证
2, 但是针对Form中的某一个input做自定义验证validator时,input的输入过程中一旦校验不符合,控制台会打印出提示信息,但是页面没有显示
What is expected?
自定义校验时,不符合的信息显示在页面
What is actually happening?
不显示在页面却在控制台显示
1、对modal使用Form.create()包裹
const WrappedPermissionModal = Form.create()(PermissionModal);
2、自定义validator
/**
*/
private validatorForURL = (rule: any, value: string, callback: any) => {
// 获取所有的权限
if (!value) {
// 为空
callback();
return;
}
for (let i = 0; i < this.props.tableData.length; i ) {
if (this.props.tableData[i].url.toLocaleLowerCase() === value.replace(/\s/g, '').toLocaleLowerCase()) {
callback('该URL已存在,请保持唯一');
} else {
callback();
}
}
callback();
}
The text was updated successfully, but these errors were encountered: