Commit d03d6815 by Qiang Xue

Fixes #928: client validation should be applied to active attributes only.

parent b4b9ad48
...@@ -589,9 +589,13 @@ class ActiveField extends Component ...@@ -589,9 +589,13 @@ class ActiveField extends Component
*/ */
protected function getClientOptions() 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; $enableClientValidation = $this->enableClientValidation || $this->enableClientValidation === null && $this->form->enableClientValidation;
if ($enableClientValidation) { if ($enableClientValidation) {
$attribute = Html::getAttributeName($this->attribute);
$validators = array(); $validators = array();
foreach ($this->model->getActiveValidators($attribute) as $validator) { foreach ($this->model->getActiveValidators($attribute) as $validator) {
/** @var \yii\validators\Validator $validator */ /** @var \yii\validators\Validator $validator */
......
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