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

Silverstripe3 Dropdown multiselect


Go to End


2 Posts   2498 Views

Avatar
merrick_sd

Community Member, 99 Posts

14 November 2012 at 12:56am

I want to have a multi select drop down menu so the Admin user can choose to show certain individuals on any Page.

page.php getCMSFields code

 // get all existing individuals
          $individuals = DataObject::get('Individual');
		 
		      if (!empty($individualss)) {
		            // create an array('ID'=>'Name')
		         $map = $individuals->toDropdownMap('ID', 'FullName');
		            // create a Checkbox group based on the array
		         $fields->addFieldToTab('Root.IntroPanel',
		              new CheckboxSetField(
		                  $name = "Individuals",
		                   $title = "Select Contacts",
		                 $source = $map
		           ));

I think this needs to be differnt in silverstripe3

$map = $individuals->toDropdownMap('ID', 'FullName');

I was thinking if this isn't posible maybe i could create a shortcode, but a shortcode would not be easier for the admin user.

Attached Files
Avatar
merrick_sd

Community Member, 99 Posts

14 November 2012 at 1:07am

$map = $individuals->map('ID', 'FullName');

answered my own question