Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Page.php and Adding Fields

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

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

Page: 1
Go to End
Author Topic: 1164 Views
  • JKendall
    Avatar
    Community Member
    3 Posts

    Page.php and Adding Fields Link to this post

    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;
       }

    }

    ?>

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Page.php and Adding Fields Link to this post

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

  • JKendall
    Avatar
    Community Member
    3 Posts

    Re: Page.php and Adding Fields Link to this post

    Thanks willr, that was the issue.

    1164 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.