D
D
devrud2016-04-13 23:15:45
Yii
devrud, 2016-04-13 23:15:45

How to add exception for yii2 validator unique?

There is a nice built-in validator in Yii. You can add a rule for checking the uniqueness of mail with this line

['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Этот почтовый ящик уже занят.'],

Is it possible to use the same rule, for example, on the page for editing personal data, so that you can check for uniqueness, but add your own mail to the exception.
Now when the user does not change the mail and submits the form, the validator complains that such mail exists.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DuD, 2016-04-13
@DuD

You need to use scripts.
phpinfo.info/yii2-scenario-rules

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question