Answer the question
In order to leave comments, you need to log in
How to make rules dependent on another field in yii2?
In the registration form model, you need to check by phone or mail so that at least one of the fields is filled.
How to do it in feng shui yii, through scripts?
Answer the question
In order to leave comments, you need to log in
It was here somewhere...
[['phone', 'email'], 'required',
'when' => function () {
if (!$this->phone && !$this->email) {
$this->addError('phone', 'Необходимо указать либо телефон, либо email.');
$this->addError('email', 'Необходимо указать либо телефон, либо email.');
}
},
'whenClient' => 'function (attribute, value) { return !$(\'#order-phone\').val().length && !$(\'#order-email\').val().length ;}',
'message' => Yii::t('app', 'Необходимо указать либо телефон, либо email.')
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question