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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Custom Field on Page Class


Go to End


3 Posts   1809 Views

Avatar
bmc38119

Community Member, 45 Posts

12 April 2009 at 1:06pm

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?

Avatar
Carbon Crayon

Community Member, 598 Posts

12 April 2009 at 1:17pm

Edited: 12/04/2009 1:19pm

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! :)

Avatar
bmc38119

Community Member, 45 Posts

14 April 2009 at 2:34am

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

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