Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » ListboxField

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

Page: 1
Go to End
Author Topic: 958 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    ListboxField Link to this post

    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!

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: ListboxField Link to this post

    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

  • Hattori
    Avatar
    Community Member
    20 Posts

    Re: ListboxField Link to this post

    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');

    958 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.