user3262786
user3262786

Reputation: 81

Datepicker in silverstripe

class Article extends Page { // Model
static $db = array(
   'Date' => 'Date',
   'Author'=>'Text'
);
 private static $has_one = array(

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

 $fields->addFieldToTab('Root.Content.Main', $date = new DateField('Date'),'Content');
 DateField::create('MyDate')->setConfig('showcalendar', true);
  $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
          return $fields;
   }    
}

The above code should show datepicker but it is not showing..
Plz help me with this..

Upvotes: 1

Views: 406

Answers (1)

g4b0
g4b0

Reputation: 951

Try this:

$fields->addFieldToTab('Root.Content.Main', DateField::create('MyDate')->setConfig('showcalendar', true),'Content');

DateField::create() is a Factory Method for DateField, so it will return a DateField object.

Upvotes: 2

Related Questions