ExistValidator refactoring

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

View File

@@ -97,13 +97,15 @@ class ExistValidator extends Validator
$params = [$targetAttribute => $object->$attribute];
}
if (!$this->allowArray) {
foreach ($params as $value) {
if (!$this->allowArray && is_array($value)) {
if (is_array($value)) {
$this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.'));
return;
}
}
}
$targetClass = $this->targetClass === null ? get_class($object) : $this->targetClass;
$query = $this->createQuery($targetClass, $params);