Conditional Validation

I have AutoFlag and ScriptId fileds in a table.

In the form AutoFlag is a checkbox and ScriptID field is a drop down.

I need to put a validation on ScriptID.

If AutoFlag is checked in the form then ScriptID cannot be blank. Use must select the ScriptID.

If AutoFlag is not checked then need not validate for ScriptID.

Hi,

Sadely you can’t do it with validator’s present in the core of yii but there a are extensions who do it

econditionalvalidator

or

yii-conditional-validator

or if you want to learn more about how to do your own validator you can read

create your own validation rule

Good luck for next.

Thanks riemann,

I got this working through Yii-conditional-validator.

Good for you ^_^