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.

Data Model Questions /

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

Adding option drop-downs to pages


Go to End


2 Posts   674 Views

Avatar
Spaghetti

Community Member, 32 Posts

11 May 2012 at 3:02am

I'm trying to figure out how to add an option on my CMS editor page, sidebar content. So far I've done this:

function getCMSFields() 
   { 
      $fields = parent::getCMSFields(); 
      $fields->addFieldToTab(
	     "Root.Content.Sidebar",
		 new HTMLEditorField('SideContent','Sidebar content')); 
		 
	  $fields->addFieldToTab(
	     "Root.Content.Sidebar",
		  new OptionsetField(
		    'ShowSocial',
		    $title = 'Show social widgets on this page',
		    $source = array(
			  '1' => 'show','2' => 'hide'),
			'1'
		    ));			  
      return $fields;
   }

In my page controller, which shows the controls but doesn't save their state when I click save. What am I missing?

Avatar
novaweb

Community Member, 116 Posts

11 May 2012 at 8:57am

You probably need to declare:

static $db = array(); or a $has_one or $has_many relationship titled 'ShowSocial'

Else you are giving the program the interface to do what you want, but you're not giving it anywhere to be saved.

Chur