Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Date Picker in CMS

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

Page: 1
Go to End
Author Topic: 3185 Views
  • J2-Paul
    Avatar
    Community Member
    51 Posts

    Date Picker in CMS Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Date Picker in CMS Link to this post

    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.

  • J2-Paul
    Avatar
    Community Member
    51 Posts

    Re: Date Picker in CMS Link to this post

    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 {

    }

    ?>

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Date Picker in CMS Link to this post

    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);

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Date Picker in CMS Link to this post

    i know this is old, but this worked for me

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

    3185 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.