Jump to:

23478 Posts in 18950 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Silverstripe3 Dropdown multiselect

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

Page: 1
Go to End
Author Topic: 575 Views
  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Silverstripe3 Dropdown multiselect Link to this post

    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
  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Re: Silverstripe3 Dropdown multiselect Link to this post

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

    answered my own question

    575 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.