Yii Framework Forum: Compare Greater Than Value With Other Attribute With Compare Rule - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Compare Greater Than Value With Other Attribute With Compare Rule Rate Topic: ***** 1 Votes

#1 User is offline   Abhishek Shah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 20-July 12
  • Location:Ahmedabad,India

Posted 20 September 2013 - 01:27 AM

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. ::)
1

#2 User is offline   Abhishek Shah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 20-July 12
  • Location:Ahmedabad,India

Posted 20 September 2013 - 05:28 AM

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.
0

#3 User is offline   xJose 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 06-February 14

Posted 02 April 2014 - 11:58 AM

thanks! this helped me a lot.
0

#4 User is offline   Abhishek Shah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 20-July 12
  • Location:Ahmedabad,India

Posted 10 April 2014 - 04:23 AM

View PostxJose, on 02 April 2014 - 11:58 AM, said:

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users