mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 04:18:29 +08:00
fix: validateOnChange=false时,提交后修改内容,表单不校验
当配置validateOnChange=false时,如果该xiang填写正确,点击提交。这时候修改该项目的内容,让其不符合校验规则,再次点击提交,表单不会校验该项内容。 我认为this.model.valid保存的是发生变化前该项目的状态,当发生变化时,该项model也应该重置。 复现demo: gif: https://github.com/DuLinRain/pictures/blob/master/amis-bug1.gif?raw=true mp4: https://github.com/DuLinRain/pictures/blob/master/amis-bug1.mp4?raw=true 复现代码如下: { "$schema": "https://houtai.baidu.com/v2/schemas/page.json#", "title": "表单验证示例", "toolbar": "<a target='_blank' href='/docs/renderers/Form/FormItem'>文档</a>", "body": [ { "type": "form", "autoFocus": false, "messages": { "validateFailed": "请仔细检查表单规则,部分表单项没通过验证" }, "title": "表单", "actions": [ { "type": "submit", "label": "提交" } ], "api": "/api/mock2/form/saveFormFailed?waitSeconds=2", "mode": "horizontal", "controls": [ { "name": "minLength", "type": "text", "label": "长度限制", "validations": "minLength:10", "validateOnChange": false } ] } ] }
This commit is contained in:
parent
0a4eb65f74
commit
1dde199f03
@ -380,7 +380,7 @@ export default class FormControl extends React.PureComponent<
|
|||||||
(validateOnChange !== false && (form.submited || this.model.validated))
|
(validateOnChange !== false && (form.submited || this.model.validated))
|
||||||
) {
|
) {
|
||||||
this.lazyValidate();
|
this.lazyValidate();
|
||||||
} else if (validateOnChange === false && !this.model.valid) {
|
} else if (validateOnChange === false) {
|
||||||
this.model.reset();
|
this.model.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user