Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate start date should be less than end date in Yii [closed]

My table has (among other columns) a start date and end date. I need to validate that the start date is less than the end date in Yii.

Do I validate that?

like image 798
siddharth Avatar asked Dec 01 '22 03:12

siddharth


1 Answers

Use the CCompareValidator for comparison validation in the rules() method of your model:

array(
  'event_end_date',
  'compare',
  'compareAttribute'=>'event_start_date',
  'operator'=>'>', 
  'allowEmpty'=>false , 
  'message'=>'{attribute} must be greater than "{compareValue}".'
),
like image 157
ayush Avatar answered Dec 04 '22 09:12

ayush