From 44a85b8e60e33ad6121f8fb280d083fbd766fe2d Mon Sep 17 00:00:00 2001 From: Yamen Sharaf Date: Wed, 26 Sep 2018 04:50:50 +0200 Subject: [PATCH] Form: emits error message on validate event (#12860) * Form: Emits error message on validate events * Update form.md --- examples/docs/en-US/form.md | 2 +- examples/docs/es/form.md | 6 +++--- examples/docs/zh-CN/form.md | 2 +- packages/form/src/form-item.vue | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/docs/en-US/form.md b/examples/docs/en-US/form.md index c4ad0d9ae..7fd013c72 100644 --- a/examples/docs/en-US/form.md +++ b/examples/docs/en-US/form.md @@ -858,7 +858,7 @@ All components in a Form inherit their `size` attribute from that Form. Similarl ### Form Events | 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 diff --git a/examples/docs/es/form.md b/examples/docs/es/form.md index 86db26651..f8b9abda3 100644 --- a/examples/docs/es/form.md +++ b/examples/docs/es/form.md @@ -871,9 +871,9 @@ Todos los componentes de un formulario heredan su atributo `size`. De manera sim ### Form Events -| 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. | +| 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, mensaje de error si existe. | ### Form-Item Atributos diff --git a/examples/docs/zh-CN/form.md b/examples/docs/zh-CN/form.md index a73226076..b237bea24 100644 --- a/examples/docs/zh-CN/form.md +++ b/examples/docs/zh-CN/form.md @@ -846,7 +846,7 @@ W3C 标准中有如下[规定](https://www.w3.org/MarkUp/html-spec/html-spec_8.h ### Form Events | 事件名称 | 说明 | 回调参数 | |--------- |-------- |---------- | -| validate | 任一表单项被校验后触发 | 被校验的表单项 prop 值,校验是否通过 | +| validate | 任一表单项被校验后触发 | 被校验的表单项 prop 值,校验是否通过,错误消息(如果存在) | ### Form-Item Attributes diff --git a/packages/form/src/form-item.vue b/packages/form/src/form-item.vue index a5e8e2516..e55967d2c 100644 --- a/packages/form/src/form-item.vue +++ b/packages/form/src/form-item.vue @@ -199,7 +199,7 @@ this.validateMessage = errors ? errors[0].message : ''; 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() {