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.

General Questions /

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

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

ListboxField


Reply


3 Posts   983 Views

Avatar
bebabeba

Community Member, 193 Posts

5 January 2011 at 8:48pm

Hi!
I need help with ListboxField. I use this to select more than 1 value in my select. This code seems correct but when save field in my record in database i found 'array' and not my values. This is my code...

$source = array(
"1" => "one",
"2" => "two",
"3" => "three"
);

$fields->addFieldToTab('Root.Content.Main', new ListboxField('ss_multikeyword','Parole chiave',$source,$value = 1,'',$multiple=true), 'Content');

Thanks!

Avatar
biapar

Forum Moderator, 435 Posts

6 January 2011 at 10:06am

Try:

$lista = array(
"1" => "one",
"2" => "two",
"3" => "three"
);

$field = new ListboxField('ss_multikeyword', "Parole Chiave", $source= $lista );

$field->setMultiple(true);

$fields->addFieldToTab("Root.Content.Main", $field);

Bye

Avatar
Hattori

Community Member, 20 Posts

12 October 2011 at 4:36am

Edited: 12/10/2011 4:36am

You need to increase the size of element greater than 1

$fields->addFieldToTab('Root.Content.Main', new ListboxField('ss_multikeyword','Parole chiave',$source,$value = 1,10, $multiple=true), 'Content');