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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Can't Save ListBoxField With Multiple Vals?


Go to End


9 Posts   4549 Views

Avatar
_Vince

Community Member, 165 Posts

6 July 2009 at 1:42pm

Edited: 06/07/2009 1:45pm

Ok, it finally seems to be working! :D

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, '' );

$field->setMultiple(true);

$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! :D

Go to Top