chore: form 渲染器添加 setErrors 方法可以外部设置表单错误 (#5851)

This commit is contained in:
liaoxuezhi 2022-12-01 10:13:21 +08:00 committed by GitHub
parent 9d762f2806
commit e61194ea7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}