Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Can't Save ListBoxField With Multiple Vals?

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

Page: 1 2
Go to End
Author Topic: 2954 Views
  • _Vince
    Community Member
    161 Posts

    Re: Can't Save ListBoxField With Multiple Vals? Link to this post

    Ok, it finally seems to be working!

    The explode() suggestion was MOSTLY right (or I misunderstood the suggestion, in which case it was COMPLETELY right!)

    Trying to set the $value parameter did nothing to change the selected items, which continued to reflect the first value on a comma separated string, no matter what I did.

    What I eventually did was this:

    function getCMSFields() {

    //cast the incoming DB value into an array
    $this->Kit_Elements = explode(",", $this->Kit_Elements);

    $field = new ListboxField('Kit_Elements', "Kit Elements", $source= $productsMap, '', $size=4, '' );


       $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.KitElements", $field);
       return $fields;


    It DOES seem a tad laborious and just plain weird, but it also seems to be working.

    Thanks Will R. for your help and interest!

Page: 1 2
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.