Jump to:

22977 Posts in 11741 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Custom Field on Page Class

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1347 Views
  • bmc38119
    Avatar
    Community Member
    45 Posts

    Custom Field on Page Class Link to this post

    I have a scenario where i have added a custom field (Navigation Image) to the Page Class - but I do not want this custom field to be available on all other Classes that extend the Page Class. Is the best way to do this is to add $fields->removeFieldFromTab to all the Classes that extend Page Class? Or is there a better, more efficient means of doing this?

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Custom Field on Page Class Link to this post

    Hi

    You can do this instead:

       if($this->ClassName == "Page")
          $fields->addFieldToTab("Root.Content.Main", new TextField("PageField"));

    Infact that's a pretty good snippet for SSbits, thanks!

  • bmc38119
    Avatar
    Community Member
    45 Posts

    Re: Custom Field on Page Class Link to this post

    exactly what i was looking for and worked like a charm!

    also, checked ssbits.com. great resource - had not come across this yet.

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