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.

General Questions /

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

Silverstripe3 Dropdown multiselect


Reply


2 Posts   681 Views

Avatar
merrick_sd

Community Member, 97 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, 97 Posts

14 November 2012 at 1:07am

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

answered my own question