Changeset 11156
- Timestamp:
- Mar 24, 2009, 11:06:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/form/CommunityEventForm.class.php
r11155 r11156 38 38 $this->setWidget('area', new sfWidgetFormInput()); 39 39 40 $this->setValidator('application_deadline', new sfValidatorDate(array( 41 'required' => false, 42 'min' => time() 43 ), array('min' => 'The date must be after now.'))); 44 45 $this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateOpenDate')))); 46 $this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateApplicationDeadline')))); 47 40 48 $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('community_event_form'); 41 49 } 50 51 public function validateOpenDate($validator, $value) 52 { 53 if ($this->isNew()) 54 { 55 $dateValidator = new sfValidatorDate(array('min' => time()), array('min' => 'The date must be after now.')); 56 $value['open_date'] = $dateValidator->clean($value['open_date']); 57 } 58 59 return $value; 60 } 61 62 public function validateApplicationDeadline($validator, $value) 63 { 64 if ($value['application_deadline']) 65 { 66 if (strtotime($value['application_deadline']) > strtotime($value['open_date'])) 67 { 68 throw new sfValidatorError($validator, 'invalid'); 69 } 70 } 71 72 return $value; 73 } 74 42 75 }
Note: See TracChangeset
for help on using the changeset viewer.