Validation - perform if NOT in specific scenario

Hi,

Can I tell Yii to do validation in all senarios (including the general not-specified scenario) BUT specific one?

I mean, having something like:


'user_id', 'required', '!register'

which means that user_id field will be required in ALL cases BUT the ‘register’ scenario.

I think this is not possible. Will be happy to taught otherwise.

Thanks!

You can set an attribute as unsafe for a specified scenario.

so I could achieve what I asked for, but with no "mass assignment" of the specific element (user_id in my example). I guess this is an acceptable way to achieve what I wanted. Not too intuitive from reading the code but works :slight_smile: (Thanks for the swift help!)

BTW, the complete picture involves creating two AR objects in a single form where there’s dependency between both (one’s PK is needed and used in the other object as an FK). See more about this problem in the comments of the following wiki article

Thanks again,

Boaz.