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.

Archive

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

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

Page.php and Adding Fields


Reply

3 Posts   1177 Views

Avatar
JKendall

20 June 2008 at 8:21am (Last edited: 20 June 2008 8:22am), Community Member, 3 Posts

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

20 June 2008 at 1:51pm Forum Moderator, 5511 Posts

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

Avatar
JKendall

21 June 2008 at 12:52am Community Member, 3 Posts

Thanks willr, that was the issue.