From b0f95bd52c5987afe9a3d50b504e53c912163bf3 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 9 Dec 2016 16:30:21 +0200 Subject: [PATCH] EMongoExistValidator not uses criteria parameter EMongoExistValidator not uses criteria parameter --- validators/EMongoExistValidator.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/validators/EMongoExistValidator.php b/validators/EMongoExistValidator.php index 6f4b0c0..e483f00 100644 --- a/validators/EMongoExistValidator.php +++ b/validators/EMongoExistValidator.php @@ -74,10 +74,12 @@ protected function validateAttribute($object, $attribute) $attributeName = $this->attributeName === null ? $attribute : $this->attributeName; $finder = EMongoDocument::model($className); - $criteria = array($attributeName => $this->mongoId ? new MongoId($value) : $value); + $criteria = $this->criteria; + $criteria[$attributeName] = $this->mongoId ? new MongoId($value) : $value; + if(!$finder->exists($criteria)){ $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" is invalid.'); $this->addError($object, $attribute, $message, array('{value}' => CHtml::encode($value))); } } -} \ No newline at end of file +}