Skip to content

Commit

Permalink
Use field scaffolding for generating date time CMS fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajshort committed Feb 23, 2013
1 parent 54ab09e commit a5d8160
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions code/CalendarDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ class CalendarDateTime extends DataObject


public function getCMSFields() {
DateField::set_default_config('showcalendar', true);
$f = new FieldList(
new DateField('StartDate',_t('CalendarDateTime.STARTDATE','Start date')),
new DateField('EndDate',_t('CalendarDateTime.ENDDATE','End date')),
new TimeField('StartTime', _t('CalendarDateTime.STARTTIME','Start time')),
new TimeField('EndTime', _t('CalendarDateTime.ENDTIME','End time')),
$fields = parent::getCMSFields();

$fields->removeByName('EventID');
$fields->addFieldsToTab('Root.Main', array(
$start = new DateField('StartDate',_t('CalendarDateTime.STARTDATE', 'Start date')),
$end = new DateField('EndDate',_t('CalendarDateTime.ENDDATE', 'End date')),
new TimeField('StartTime', _t('CalendarDateTime.STARTTIME', 'Start time')),
new TimeField('EndTime', _t('CalendarDateTime.ENDTIME', 'End time')),
new CheckboxField('AllDay', _t('CalendarDateTime.ALLDAY','This event lasts all day'))
);
));

$this->extend('updateCMSFields', $f);
$start->setConfig('showcalendar', true);
$end->setConfig('showcalendar', true);

return $f;
$this->extend('updateCMSFields', $fields);
return $fields;
}


Expand Down

0 comments on commit a5d8160

Please sign in to comment.