Hello,
While following Tutorial 2 (http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site) trying to create an Article Page and Article Holder Page. At last step I get an "Error Saving Content" message and the Article Page is never saved.
Having read through past forum entries I found an interesting point raised by a member (http://silverstripe.org/archive/show/5862#post5862)
If the Date field is completely left out and we only create an author field then everything works fine. The member suggests that puting the Date field in the static $has_one = array( ) part works. For me this doesn't work and I still get the same error (and yes I have repeatedly tried flushing http://www.sitename.com/dev/build?flush=1). Unfortunately, though many people have raised this issue no one has ever given a solution to the problem.
Is this a bug or is the code in the tutorial wrong? If the latter, then can someone please change the tutorial as many people (including myself) are spendng hours trying to make it work.
It may be that I have misunderstood something.
For your easy reference, the final versions of ArticlePage.php and ArticleHolder.php are as follows:
-----------------------------
ArticlePage.php
-----------------------------
<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
return $fields;
}
}
class ArticlePage_Controller extends Page_Controller {
}
?>
AND
--------------------------
ArticleHolder.php
--------------------------
<?php
/**
* Defines the ArticleHolder page type
*/
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('ArticlePage');
}
class ArticleHolder_Controller extends Page_Controller {
}
?>
I would REALLY REALLY REALLY appreciate it if someone could point out what is going wrong here as I really want to understand this and continue with the site.