mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
chore: form 渲染器添加 setErrors 方法可以外部设置表单错误 (#5851)
This commit is contained in:
parent
9d762f2806
commit
e61194ea7a
@ -809,6 +809,11 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
});
|
||||
}
|
||||
|
||||
setErrors(errors: {[propName: string]: string}, tag = 'remote') {
|
||||
const {store} = this.props;
|
||||
store.setFormItemErrors(errors, tag);
|
||||
}
|
||||
|
||||
clearErrors() {
|
||||
const {store} = this.props;
|
||||
|
||||
@ -1837,10 +1842,7 @@ export class FormRenderer extends Form {
|
||||
// 配了submit事件的表示将提交逻辑全部托管给事件
|
||||
const {dispatchEvent, onEvent} = this.props;
|
||||
const submitEvent = onEvent?.submit?.actions?.length;
|
||||
const dispatcher = await dispatchEvent(
|
||||
'submit',
|
||||
this.props.data
|
||||
);
|
||||
const dispatcher = await dispatchEvent('submit', this.props.data);
|
||||
if (dispatcher?.prevented || submitEvent) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user