Compare Greater Than Value With Other Attribute With Compare Rule

I have to check that end date should be greater than start date.

I was using compare for password,confirm_password etc.It was checked by default operator of compare validation "==".

When I tried for >,I got a solution,there is a attribute of operator in compareValidaor.By which I achieve my goal.See rule,


array('end_date','compare','compareAttribute'=>'start_date','operator'=>'>','message'=>'Start Date must be less than End Date'),

similarly you can check <,<=,>=,> operators with it.

If you want to compare with value,

suppose percentage should be less than 100,you can do it with,‘compareValue’


array('percentage','compare','compareValue'=>'100','operator'=>'<','message'=>'Percentage must be less than 100'),

Hope,It may helpful to others. ::)

I have checked with current month with date,for next months date ,if I try to take date less than from date,i.e. start date:31st august,end date:1st september,than,it wll not take,so for date ,do not follow this way,but when you have to check values of 2 attributes,you do this way.

thanks! this helped me a lot.

It is ok.Ask for doubts,if you stuck up.Yii comminity is very helpful,will solve your doubts.

useful thanks

FROM WHERE I SHOULD START LEARNING IN YII

Thanks.