Skip to content

Commit

Permalink
EMongoExistValidator not uses criteria parameter
Browse files Browse the repository at this point in the history
EMongoExistValidator not uses criteria parameter
  • Loading branch information
Kison authored Dec 9, 2016
1 parent 3c57ad3 commit b0f95bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions validators/EMongoExistValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
}
}

0 comments on commit b0f95bd

Please sign in to comment.