From d03d681583b1bdc8ea0246ca610bbb1bb3a6fd73 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 30 Sep 2013 10:14:08 -0400 Subject: [PATCH] Fixes #928: client validation should be applied to active attributes only. --- framework/yii/widgets/ActiveField.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/yii/widgets/ActiveField.php b/framework/yii/widgets/ActiveField.php index ea8aa1b..7df67fa 100644 --- a/framework/yii/widgets/ActiveField.php +++ b/framework/yii/widgets/ActiveField.php @@ -589,9 +589,13 @@ class ActiveField extends Component */ protected function getClientOptions() { + $attribute = Html::getAttributeName($this->attribute); + if (!in_array($attribute, $this->model->activeAttributes(), true)) { + return array(); + } + $enableClientValidation = $this->enableClientValidation || $this->enableClientValidation === null && $this->form->enableClientValidation; if ($enableClientValidation) { - $attribute = Html::getAttributeName($this->attribute); $validators = array(); foreach ($this->model->getActiveValidators($attribute) as $validator) { /** @var \yii\validators\Validator $validator */