As in the Exist Validator to search 2 fields at once?

Hi friends!

There is a need for validation to check the existence of records in the database, but only to look for not one field in table a in two. It can crank out standard methods exist-validator?

Now it looks like this:

['zip', 'exist', 'targetClass' => ZipKz::className(), 'targetAttribute' => 'zip_new', 'when' => function($model){
 return $model->geo == 'KZ';
}],


Ie the zip box is checked in the index table, and this table 2 columns (zip_new, zip_old), and to look for a match on both.
June 8th 19 at 16:44
1 answer
June 8th 19 at 16:46
www.yiiframework.com/doc-2.0/yii-validators-existv...

['zip', 'exists', 'targetClass' => ZipKz::className(), 'targetAttribute' => ['zip_old', 'zip_new'], 'when' => function($model){
 return $model->geo == 'KZ';
}],
Choate I have validiya passes this test as if it is not - audrey_Kautz commented on June 8th 19 at 16:49
it means that the values in the database have either geo != KZ - violet_Dibbe commented on June 8th 19 at 16:52
or when not working in conjunction with exist - audrey_Kautz commented on June 8th 19 at 16:55
,
or when not working in conjunction with exist

unlikely, but you can also check a simple example

and in the logs (debug) to check if the query in the database and what - Henderson_Beat commented on June 8th 19 at 16:58

Find more questions by tags Yii