Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Help with Listbox Field

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1284 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Help with Listbox Field Link to this post

    Hi,

    I am having a heck of a time getting selected items from a ListboxField to save properly in the database. I'm hoping someone might be able to help me. Here is my code:

    <?php

    class Networks extends DataObject {

    function getCMSFields_forPopup() {

          $fields = new FieldSet();

           $VerticalSet = DataObject::get("Verticals", '','VerticalName ASC','','');
           $dropdownfield = new ListboxField('Verticals', 'Select Associated Verticals', $VerticalSet->toDropDownMap('ID', 'VerticalName'),'VerticalName', 10, true, '');
    $fields->push($dropdownfield);

          return $fields;

       }

    }
    ...where "Verticals" is a separate table with a field called Verticals where I wish to store the selected items in this Listbox. But I have two problems.

    1.) When I pop up the window to add or modify a Network (that's the DataObject which needs to contain this info),I get this error @ the top of the page:

    "Notice: Undefined variable: options in C:\wwwroot\wamp\www\adify\sapphire\forms\ListboxField.php on line 68"

    2.) The value of the field stores in the database as "Array".

    What am I doing wrong???

    I know my Value paramter (the 4th param of the ListboxField contrsuctor is wrong, but I don't know what it SHOULD be).

    Thanks everyone in advance for your help!

    //Garrett

    1284 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.