Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » New fields in content not getting added

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: 1877 Views
  • Decisive Flow
    Avatar
    Community Member
    73 Posts

    New fields in content not getting added Link to this post

    I've created a little 'blurb' text area for a page type, when I flush the database, it appears to create the field, but it never shows up in the back end. On another site, it's working fine, and I can't think of why it's not here.

    I have:
    1) added this code (below)
    2) flushed database
    3) assigned new page type to content items

    UPDATE: I've just pulled the code over to another page type and it works fine. Just not in the new one...

    PS. Do I get a gold star for asking the most questions?

    class TeamMember extends Page {
       
    static $db = array(
          "IntroductionText" => "Text",
          "Blurb" => "Text",
       );
    }

    function getCMSFields() {
          $fields = parent::getCMSFields();
          
          $fields->addFieldToTab("Root.Content.Main", new TextareaField("IntroductionText", "Short Blurb"), "Content");
          $fields->addFieldToTab("Root.Content.Main", new TextareaField("Blurb", "Blurb"), "Content");

          return $fields;
       }   

    class TeamMember_Controller extends Page_Controller {
    }

    ?>

  • Simon
    Avatar
    Core Development Team
    27 Posts

    Re: New fields in content not getting added Link to this post

    If thats a direct copy of your code, you'll need to move the function getCMSFields() into the class for it to do anything

    (I think its just a misplaced squigly bracket)

    IE:

    class TeamMember extends Page {

    static $db = array(
    "IntroductionText" => "Text",
    "Blurb" => "Text",
    );
    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab("Root.Content.Main", new TextareaField("IntroductionText", "Short Blurb"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new TextareaField("Blurb", "Blurb"), "Content");

    return $fields;
    }

    }

    We should run a competition or something for the person that discovers the most bugs :-p

  • Decisive Flow
    Avatar
    Community Member
    73 Posts

    Re: New fields in content not getting added Link to this post

    eh, stupid }'s ;) thanks, fixed now.

    Man, nothing like a little PHP to make you feel braindead.

    I'm in for the bug finding, though I believe I am more of a bug creator, all things ocnsidered ;)

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: New fields in content not getting added Link to this post

    I'm sure we could create a ranking board for forum members who ask the most questions. I think you're #1 at the moment anyways. ;)

    Cheers,
    Sean

    1877 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.