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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Can't Save ListBoxField With Multiple Vals?


Go to End


9 Posts   5795 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