Commit 44a85b8e authored by Yamen Sharaf's avatar Yamen Sharaf Committed by hetech

Form: emits error message on validate event (#12860)

* Form: Emits error message on validate events

* Update form.md
parent 99a1f4f3
...@@ -858,7 +858,7 @@ All components in a Form inherit their `size` attribute from that Form. Similarl ...@@ -858,7 +858,7 @@ All components in a Form inherit their `size` attribute from that Form. Similarl
### Form Events ### Form Events
| Event Name | Description | Parameters | | Event Name | Description | Parameters |
|----------- |------------ |----------- | |----------- |------------ |----------- |
| validate | triggers after a form item is validated | prop name of the form item being validated, whether validation is passed | | validate | triggers after a form item is validated | prop name of the form item being validated, whether validation is passed and the error message if not |
### Form-Item Attributes ### Form-Item Attributes
......
...@@ -872,8 +872,8 @@ Todos los componentes de un formulario heredan su atributo `size`. De manera sim ...@@ -872,8 +872,8 @@ Todos los componentes de un formulario heredan su atributo `size`. De manera sim
### Form Events ### Form Events
| Nombre | Descripción | Parametros | | Nombre | Descripción | Parametros |
| -------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | | -------- | ---------------------------------------------------- | ------------------------------------------------------------ |
| validate | se dispara después de validar un item del formulario | la propiedad (`prop name`) nombre del item del form que se esta validando, si la validacion paso o no. | | validate | se dispara después de validar un item del formulario | la propiedad (`prop name`) nombre del item del form que se esta validando, si la validacion paso o no, mensaje de error si existe. |
### Form-Item Atributos ### Form-Item Atributos
......
...@@ -846,7 +846,7 @@ W3C 标准中有如下[规定](https://www.w3.org/MarkUp/html-spec/html-spec_8.h ...@@ -846,7 +846,7 @@ W3C 标准中有如下[规定](https://www.w3.org/MarkUp/html-spec/html-spec_8.h
### Form Events ### Form Events
| 事件名称 | 说明 | 回调参数 | | 事件名称 | 说明 | 回调参数 |
|--------- |-------- |---------- | |--------- |-------- |---------- |
| validate | 任一表单项被校验后触发 | 被校验的表单项 prop 值,校验是否通过 | | validate | 任一表单项被校验后触发 | 被校验的表单项 prop 值,校验是否通过,错误消息(如果存在) |
### Form-Item Attributes ### Form-Item Attributes
......
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
this.validateMessage = errors ? errors[0].message : ''; this.validateMessage = errors ? errors[0].message : '';
callback(this.validateMessage, invalidFields); callback(this.validateMessage, invalidFields);
this.elForm && this.elForm.$emit('validate', this.prop, !errors); this.elForm && this.elForm.$emit('validate', this.prop, !errors, this.validateMessage || null);
}); });
}, },
clearValidate() { clearValidate() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment