开发者

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

开发者 https://www.devze.com 2023-02-10 07:22 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago. 开发者_C百科

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?


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}".'
),
0

精彩评论

暂无评论...
验证码 换一张
取 消