From 7d999b265281d4b4183110ebbbdc4da7930b19c2 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 2 May 2013 07:40:29 -0400 Subject: [PATCH] form fix. --- framework/assets/yii.activeForm.js | 4 ++-- framework/widgets/ActiveField.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/assets/yii.activeForm.js b/framework/assets/yii.activeForm.js index e5df863..901deac 100644 --- a/framework/assets/yii.activeForm.js +++ b/framework/assets/yii.activeForm.js @@ -360,7 +360,7 @@ attribute.status = 1; if ($input.length) { - hasError = messages && $.isArray(messages[attribute.id]) && messages[attribute.name].length; + hasError = messages && $.isArray(messages[attribute.name]) && messages[attribute.name].length; var $container = $form.find(attribute.container); $container.removeClass( data.settings.validatingCssClass + ' ' + @@ -369,7 +369,7 @@ ); if (hasError) { - $form.find(attribute.error).html(messages[attribute.name][0]); + $container.find(attribute.error).html(messages[attribute.name][0]); $container.addClass(data.settings.errorCssClass); } else if (attribute.enableAjaxValidation || attribute.enableClientValidation && attribute.validate) { $container.addClass(data.settings.successCssClass); diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index a6ef58e..90c6db4 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -65,7 +65,7 @@ class ActiveField extends Component $attribute = Html::getAttributeName($this->attribute); $validators = array(); - foreach ($this->model->getValidators($attribute) as $validator) { + foreach ($this->model->getActiveValidators($attribute) as $validator) { /** @var \yii\validators\Validator $validator */ if (($js = $validator->clientValidateAttribute($this->model, $attribute)) != '') { $validators[] = $js;