From e61194ea7ac199bb2eb4b87db03ae57825ec637f Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Thu, 1 Dec 2022 10:13:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20form=20=E6=B8=B2=E6=9F=93=E5=99=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20setErrors=20=E6=96=B9=E6=B3=95=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E9=83=A8=E8=AE=BE=E7=BD=AE=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=94=99=E8=AF=AF=20(#5851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/renderers/Form.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index 8b5940502..69a0c7e08 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -809,6 +809,11 @@ export default class Form extends React.Component { }); } + 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; }