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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

MultiSelectField selected array problem


Go to End


819 Views

Avatar
Harley

Community Member, 165 Posts

1 February 2016 at 9:57am

Hi guys,

I've been using the wonderful MultiSelectField add-on http://addons.silverstripe.org/add-ons/fullscreeninteractive/silverstripe-multiselectfield on a front-end form.

This form is used to edit entries that have already been added via another form. The issue I'm having is that when retrieving an array ($FeedbackCategorySelected) to populate the field with previous selection(s) it doesn't seem to take the argument. For instance if the array was (1,3) it will only display the record for 1 and not 3.

As this field is extending the CheckboxFieldSet I would have assumed it would work in exactly the same way.

Can anyone shed any light on what could be wrong here? Code below.

Many thanks

 ...
$urlID = $this->request->param('ID');
if(is_numeric($urlID)){
	$CallEvent = DataObject::get_by_id("CallEvent", Convert::raw2sql($this->request->param('ID')));
	$Feedback = DataObject::get_by_id("Feedback", $CallEvent->FeedbackID);
	$FeedbackCategorySelected = $Feedback->FeedbackCategories;
	$FeedbackCategory = FeedbackCategoryData::get()->map('ID', 'Title')->toArray();
}
...
$fields = new FieldList(
new MultiSelectField(
	'FeedbackCategories',
	'Select feedback categories to add or remove',
	$FeedbackCategory,
	$FeedbackCategorySelected
)
...