From 3e94b2488584c38f5c034067d999f0aa33c612b6 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Tue, 13 May 2014 16:10:08 +0400 Subject: [PATCH] ExistValidator refactoring --- framework/validators/ExistValidator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/validators/ExistValidator.php b/framework/validators/ExistValidator.php index 75fe8298eb..6479395410 100644 --- a/framework/validators/ExistValidator.php +++ b/framework/validators/ExistValidator.php @@ -97,11 +97,13 @@ class ExistValidator extends Validator $params = [$targetAttribute => $object->$attribute]; } - foreach ($params as $value) { - if (!$this->allowArray && is_array($value)) { - $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.')); + if (!$this->allowArray) { + foreach ($params as $value) { + if (is_array($value)) { + $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.')); - return; + return; + } } }