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.

Form Questions /

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

ListboxField unable to set multiple = true


Go to End


2 Posts   1456 Views

Avatar
MartinPhone

Community Member, 57 Posts

6 May 2013 at 12:52pm

Edited: 06/05/2013 12:53pm

I'm feeling very stupid but no matter where I look I can't find what I'm doing wrong. I want to display a ListboxField that contains all the values I've specified in my listboxArray array. The values are there alright, I just can't set it to multiple select. I only ever get a one-value dropdownlist...

I also would like to know how to set the $size to use the size value returned by getAttributes...

$fields = parent::getCMSFields();
		
		$fields->addFieldToTab("Root.Content.Main", new ListboxField(
			   $name = "Treatments",
			   $title = "All treatments offered by practitioner",
			   $source = $listboxArray,
			   $size=8,
			   $multiple=true
			   )
			);
   		return $fields;

What am I doing wrong?

Avatar
MartinPhone

Community Member, 57 Posts

6 May 2013 at 1:11pm

OK to answer my own question I didn't realise value='', would be so important. Put that in and it works.

My question as to how to set the size to be that of the array still stands though!