Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Date Picker in CMS


Reply


5 Posts   3437 Views

Avatar
J2-Paul

Community Member, 51 Posts

23 May 2010 at 6:05am

I am running through tutorial 2 and have added Date and Author fields. However, the date fields that I have placed on the Main tab does not have a date picker. The tutorial image shows a date picker next to the field.

My enviroment: SS 2.3.3. Win2003 Server, IIS6, Helicon 3, MySQL 5.0.51a, PHP 5.2.12.

I am UK based, so not sure if my local has anything to do with it. My understanding is that NZ guys and us both use the date formats.

Any help much appreciated.

Avatar
Willr

Forum Moderator, 5513 Posts

23 May 2010 at 2:35pm

The tutorial may have been updated to 2.4 datefields - to show a date picker on 2.3.3 you should use CalendarDateField rather than DateField to get a calendar.

Avatar
J2-Paul

Community Member, 51 Posts

1 June 2010 at 11:03am

Will. Have successfully upgraded to 2.4.0. But I am still not seeing the date picker in the CMS for the tutorial article page.

Code below for ArticlePage.php. Am I doing something wrong?

<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
);

//adds icon to tree in CMS admin
static $icon = "themes/tutorial/images/treeicons/news";
static $defaults = array('ProvideComments' => true);

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Main', new DateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');

return $fields;
}

}

class ArticlePage_Controller extends Page_Controller {

}

?>

Avatar
Willr

Forum Moderator, 5513 Posts

1 June 2010 at 2:20pm

Have a look at the documentation on date fields with 2.4

http://doc.silverstripe.org/datefield

$fields->addFieldToTab('Root.Content.Main', $date = new DateField('Date'), 'Content');
$dateField->setConfig('showcalendar', true);

Avatar
Futureweb

Community Member, 233 Posts

30 May 2013 at 2:13pm

i know this is old, but this worked for me

$dateField = new DateField('Date');
$dateField->setConfig('showcalendar', true);
$fields->addFieldToTab('Root.Content.Blog', $dateField);