Jump to:

23450 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » SS3: Show Date Picker in CMS datagrid

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: 500 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    SS3: Show Date Picker in CMS datagrid Link to this post

    I have a datagrid allowing the user to add events to an event page.

    On it, I have 2 date fields so they can specify a start and end date. These fields do not show the date picker unless I comment out a line from DateField.js in Sapphire/javascript (line 12 - if(!config.showcalendar) return;).

    Is there anyway to get the date picker to show without tampering with the core?

    <?php
    class Event extends DataObject{
       public static $db = array(
          'Title' => 'Varchar(255)',
          'StartDate' => 'Date',
          'EndDate' => 'Date',
          'Summary' => 'Text',
          'Content' => 'HTMLText'
       );

       static $has_one = array(
          'WhatsOnCategory' => 'WhatsOnCategory',
          'EventImage' => 'Image'
       );

       public static $summary_fields = array(
          'Title' => 'Title'
       );
       
       public static $default_sort='StartDate';

       public function getCMSFields() {
           return new FieldList(
              new TextField('Title', 'Title'),
              new DateField('StartDate', 'StartDate'),
              new DateField('EndDate', 'EndDate'),
              new TextField('Summary', 'Summary'),
              new HTMLEditorField('Content', 'Content'),
              new UploadField('EventImage','Image')
           );
       }
    }

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: SS3: Show Date Picker in CMS datagrid Link to this post

    public function getCMSFields() {
       $fields = array();

       $fields[] = new TextField('Title', 'Title');
       $fields['StartDate'] = new DateField('StartDate', 'StartDate');
       $fields['StartDate']->setConfig('showcalendar', true);
       $fields['EndDate'] = new DateField('EndDate', 'EndDate');
       $fields['EndDate']->setConfig('showcalendar', true);
       $fields[] = new TextField('Summary', 'Summary');
       $fields[] = new HTMLEditorField('Content', 'Content');
       $fields[] = new UploadField('EventImage','Image');

       return new FieldList($fields);
    }

    500 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.