mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixes #12554: Fixed yii\validators\UniqueValidator
error of getting first model indexed by field
This commit is contained in:

committed by
Alexander Makarov

parent
19a896a299
commit
c42ef605db
@ -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;
|
||||
|
Reference in New Issue
Block a user