Following Tutorial 2: ArticlePage.php, causes a crash with:
"Fatal error: Call to a member function setConfig() on a non-object in C:\wamp\www\silverstripe\mysite\code\ArticlePage.php on line 12"
The code when adding the improving datefield instructions:
<?php
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
// JCo - Tutorial 2: Modifying Date field. Problem with the next line:
// $fields->addFieldToTab('Root.Main', $dateField = new DateField('Date','Article Date (for example: 31/07/2012)'), 'Content');
// JCo - circumventing the problem....>
$datefield = new DateField('Date','Article Date (for example: 31/07/2012)');
$datefield->setConfig('showcalendar', true);
// Tutorial 2 - SS 3.0.1 - Next line causes crash
// $dateField->setConfig('dateformat', 'dd-MM-YYYY');
$fields->addFieldToTab('Root.Main', $datefield, 'Content');
$fields->addFieldToTab('Root.Main', new TextField('Author','Author Name'), 'Content');
return $fields;
}
}
class ArticlePage_Controller extends Page_Controller {
}
------------
What I'm doing wrong?
Kind regards, K=JohnC