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.

Archive /

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

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

Help with Listbox Field


Reply


1335 Views

Avatar
Garrett

Community Member, 245 Posts

18 September 2008 at 11:18am

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