Commit 3e94b248 by Alexander Kochetov

ExistValidator refactoring

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