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.

Customising the CMS /

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

Add checkbox within visibility in page settings


Go to End


4 Posts   5486 Views

Avatar
Vix

Community Member, 60 Posts

26 September 2013 at 5:24pm

I am using 3.1 and I want to add a field to the page settings tab. I have got the following code

function getSettingsFields() {
		$fields = parent::getSettingsFields();
		$fields->addFieldToTab("Root.Settings", new CheckBoxField('ShowFooter', 'Show link in footer?'));
		return $fields;
	}

and this works great, but what I want to do is add the checkbox in the same row as 'Visibility'. So that row would read 'Show in menus?', 'Show in Search?', 'Show in Footer?' (not all menu items will be shown in the website footer for this site).

What do I need to do to add this field into that location?

Thanks
Vix

Avatar
Vix

Community Member, 60 Posts

26 September 2013 at 8:03pm

Figured it out I just had to add ,'ShowInSearch' after my new CheckBoxField.

eg:

$fields->addFieldToTab("Root.Settings", new CheckBoxField('ShowFooter', 'Show link in footer?'), 'ShowInSearch');

Avatar
neilcreagh

Community Member, 136 Posts

20 June 2017 at 4:17am

Any idea how this is done in 3.5+ ?
If I add to Root.Settings then I get a new 'Settings' tab in the main area - is it possible to add a field into the existing Settings area in 3.5+ as you've done here?

Avatar
neilcreagh

Community Member, 136 Posts

20 June 2017 at 4:31am

Update: I was trying to add this within the standard getCMSFields - I missed that you were actually updating getSettingsFields separately.
Leaving this here in case anyone else makes the same mistake