Fixes #12554: Fixed yii\validators\UniqueValidator error of getting first model indexed by field

This commit is contained in:
DrDeath72
2016-09-20 22:53:43 +05:00
committed by Alexander Makarov
parent 19a896a299
commit c42ef605db
2 changed files with 3 additions and 1 deletions

View File

@ -157,7 +157,7 @@ class UniqueValidator extends Validator
$exists = $model->getOldPrimaryKey() != $model->getPrimaryKey();
} else {
// non-primary key, need to exclude the current record based on PK
$exists = $models[0]->getPrimaryKey() != $model->getOldPrimaryKey();
$exists = reset($models)->getPrimaryKey() != $model->getOldPrimaryKey();
}
} else {
$exists = $n > 1;