From a5d8160144c461cc9014cfb0945c1e2d647d9413 Mon Sep 17 00:00:00 2001 From: ajshort Date: Sun, 24 Feb 2013 09:58:46 +1100 Subject: [PATCH] Use field scaffolding for generating date time CMS fields. --- code/CalendarDateTime.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/code/CalendarDateTime.php b/code/CalendarDateTime.php index 919056f..c126c91 100755 --- a/code/CalendarDateTime.php +++ b/code/CalendarDateTime.php @@ -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; }