21292 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 291 Views |
-
Can someone provide a working ListboxField example?

26 January 2012 at 9:50am
I've spent the better part of the last two days searching the forums and trying to get a working ListboxField (with multiple values). I originally wanted the Listbox populated with values from a Dataobject, but I'll take anything. I have a working CheckboxsetField, but the users think it takes up too much screen space. I thought ListboxField would be the solution, but I can't get it to work. If it does manage to store anything, it stores "Array".
Thanks,
Brian -
Re: Can someone provide a working ListboxField example?

27 January 2012 at 4:52am
Have you looked into the API Documentation on that Class?
http://api.silverstripe.org/2.4/forms/fields-basic/ListboxField.html
There it an example:
new ListboxField(
$name = "pickanumber",
$title = "Pick a number",
$source = array(
"1" => "one",
"2" => "two",
"3" => "three"
),
$value = 1
)If that doesnt help, post your code =)
Hope that helps
-
Re: Can someone provide a working ListboxField example?

27 January 2012 at 5:21am
Thanks for the help! That example will work with 1 value. Anytime I try to modify it to accept multiple values it stores "Array" instead of the values (even if I pick only 1)
$fields->addFieldToTab('Root.Main', new ListboxField($name = "App2", $title = "App2t", $source = array(
"1" => "one",
"2" => "two",
"3" => "three"
), $value =1,$size = 4,$multiple= true));
| 291 Views | ||
|
Page:
1
|
Go to Top |

