17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1239 Views |
-
Custom fields not showing on CMS

26 November 2008 at 2:02pm
Hello,
I was following http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site. I got the database built fine and I can create new page of type ArticleHolder and ArticlePage. However, when I'm on Article Page, I don't see new fields on CMS. I did flush on both http://mysite/db/build?flush=1 and http://mysite/admin/?flush=1.
I put the code to override getCMSFields() under mysite/code/ArticlePage.php under ArticlePage_Controller class. It seems like the function is not being called (I checked using syslog() on the function and I don't see anything)
Any pointers / help is appreciated.
-
Re: Custom fields not showing on CMS

26 November 2008 at 6:54pm
It should be in the ArticlePage class and NOT the controller. The controller class usually only has methods which are used in the templates. Things like getCMSFields() should be in the top class.
-
Re: Custom fields not showing on CMS

11 December 2008 at 10:05am
I still have no luck adding the method to the ArticlePage class, this is my code in code/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 {
}
?>
After db/build?flush=1 and multiple refreshes, it still does not show the Date and Author field when I tried to add a new ArticlePage in CMS. I'm on v2.2.3 What have I done wrong? Help!
| 1239 Views | ||
|
Page:
1
|
Go to Top |



