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:

Archive /

Our old forums are still available as a read-only archive.

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

Page.php and Adding Fields


Go to End


3 Posts   1780 Views

Avatar
JKendall

Community Member, 3 Posts

20 June 2008 at 8:21am

Edited: 20/06/2008 8:22am

Hi,

I've gone through the tutorials on setting up and extending a site with SilverStripe. I added the news section like the tutorial said, however when I go back to perform the same basic action of adding a new field to the "Page" page, upon saving or publishing the ajax loading graphic just spins like it can't save. I added a masthead image field and below is my code, if anyone can help me I'd appreciate it. This is the last thing on my to-do list for this site and I was hoping it would be easy. Thanks.

(Note: the calltoaction function works perfectly).

<?php
 
class Page extends SiteTree {

    static $db = array('Masthead'=>'text');
	static $has_one = array();
		function getCMSFields() {
			$fields = parent::getCMSFields();
			$fields->addFieldToTab('Root.Content.Main', new TextField('Masthead', 'Masthead Image'), 'Content');
			return $fields;
		}
}
 
class Page_Controller extends ContentController {

	function CallToAction(){
		$cat = DataObject::get_by_id('Page', 15);
		return $cat;
	}

}
 
?>

Avatar
Willr

Forum Moderator, 5523 Posts

20 June 2008 at 1:51pm

I believe you need to have Text instead of text. FieldTypes are case sensitive I would assume

Avatar
JKendall

Community Member, 3 Posts

21 June 2008 at 12:52am

Thanks willr, that was the issue.