ExistValidator refactoring

This commit is contained in:
Alexander Kochetov
2014-05-13 16:10:08 +04:00
parent 3a0e04f329
commit 3e94b24885

View File

@@ -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;
}
}
}