Jump to:

5519 Posts in 1734 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Multi-select listboxfield SS2.4

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

Page: 1
Go to End
Author Topic: 174 Views
  • Lazarus404
    Avatar
    Community Member
    71 Posts

    Multi-select listboxfield SS2.4 Link to this post

    Hi guys,

    So, I have a dataobject type, which is managed from the CMS. One of the page types in my site can have one or more of these dataobjects assigned.

    //page class
    public static $belongs_many_many = array(
       'DataObjectList' => 'MyDataObject',
    );

    //data object
    public static $many_many = array(
    'Pages' => 'MyPage'
    );

    The page type has a listboxfield with multiselect set to true and populated with all of the available dataobjects, like so:

    $dropdown = new ListboxField('DataObjectList', _t('DATAOBJECTS', 'Data Objects'), DataObject::get('MyDataObject', "", 'Name DESC')->toDropDownMap());
    $dropdown->setMultiple(true);
    $fields->addFieldToTab('Root.Content.Main', $dropdown, 'Content');

    Now, this displays fine in the CMS admin, but when one or more items are selected in the admin, they don't save. What do I need to do to make this happen?

    Thanks loads,
    Lee

    174 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.