Answer the question
In order to leave comments, you need to log in
How to check if two fields are identical?
There is a rules() function, the standard for Active Form. There are two fields: password and repeat password . Question: is it possible to check them for compliance through the rules? There is a built-in validator, CompareValidator , which can perform this action, but when using it, a problem arises. here is a piece of my rules:
// ...
['password_repeat', 'compare', 'compareAttribute' => 'password', 'operator' => '=','message' => 'Пароли не совпадают!'],
// ...
<?= $form->field($model, 'password')->hint('Не меньше шести символов.')?>
<?= $form->field($model, 'password_repeat')->hint('Повторите ввод пароля')?>
Answer the question
In order to leave comments, you need to log in
Compare Validator https://github.com/yiisoft/yii2/blob/master/docs/g...
remove
'operator' => '=' from the
validator parameters First you wrote the assignment operator and equals, the equals operators are == or === . And secondly, this validator has the == operator by default.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question