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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Tutorial 2 - SS 3.0.1 - dateField - crashing

Go to End

3 Posts   931 Views


Community Member, 5 Posts

9 August 2012 at 1:46pm

Edited: 09/08/2012 2:30pm

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:

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

Attached Files

Community Member, 473 Posts

9 August 2012 at 3:23pm

Variables in PHP are case sensitive. You've defined $datefield, but are trying to call a method on $dateField.


Community Member, 5 Posts

9 August 2012 at 4:11pm

I didn't catch that one. And of course, that explains the other line... :)

Kind regards,