21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 286 Views |
-
Tutorial 2 - SS 3.0.1 - dateField - crashing

9 August 2012 at 1:46pm Last edited: 9 August 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:
<?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 -
Re: Tutorial 2 - SS 3.0.1 - dateField - crashing

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.
-
Re: Tutorial 2 - SS 3.0.1 - dateField - crashing

9 August 2012 at 4:11pm
Simon,
THANK YOU!...
I didn't catch that one. And of course, that explains the other line...
Kind regards,
JohnCo.
| 286 Views | ||
|
Page:
1
|
Go to Top |

