Answer the question
In order to leave comments, you need to log in
Validation in the generated form?
Form generated with Gii. The form has several checkboxes and an input field. How to make it so that if the field is not empty, and none of the checkboxes are selected, there will be an error. And vice versa, if at least one checkbox is selected, but the field is empty, it is also an error.
P.S. If the tag is not clear, I specify - only Yii 1 !!!
Answer the question
In order to leave comments, you need to log in
As an option, write your own validator
Or through when:
[[тут атрибуты чекбоксов], 'required', 'when' => function($model) {
return $model->мой_атрибут_не_пустого_поля == null;
}],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question