Conditional Validation


(Php Anu) #1

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.


(Zendyani) #2

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.


(Php Anu) #3

Thanks riemann,

I got this working through Yii-conditional-validator.


(Zendyani) #4

Good for you ^_^