Answer the question
In order to leave comments, you need to log in
Yii - how to set up validation by condition?
I am unable to set up conditional validation for related data via the yii-conditional-validator extension.
There are categories and there are jobs, if a category is selected when adding a job, in which the value of the field type = 1, then the field with the file is required, otherwise it is optional. Relationships 'works'=>array(self::HAS_MANY, 'Work', 'id_cat') and 'cat' => array (self::BELONGS_TO, 'Cat', 'id_cat'). How can this be done with or without extension - doesn't matter?
Answer the question
In order to leave comments, you need to log in
Without an extension, you can write your own rule, in which you can check incoming data and validate them in the right way.
Using custom filters in validation rules
Creating your own validation rule
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question