L
L
Looking2014-05-28 18:03:39
Yii
Looking, 2014-05-28 18:03:39

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

1 answer(s)
D
Denis Ogurtsov, 2014-05-28
@DenisOgr

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 question

Ask a Question

731 491 924 answers to any question