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, Ed, biapar, Willr, Ingo

TableField Dropdown


Go to End
Reply


4 Posts   1958 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 October 2007 at 9:12am

I've always set up my TableFields with TextFields. Is it possible to put a DropdownField in? When i do, it appears, but it's not populated. How can I populate it?


new TableField(
         'Practice_Areas',
         'PracticeAreas',
         array(
	    'Practice_Area' => 'Practice Area',
	    'Link' => 'Link'
         ),
         array(
	    'Practice_Area' => 'TextField',
	    'Link' => 'DropdownField' /** Where do the options go?? **/
         ),
        null, 
		"PracticeAreas.AttorneyPageID = $this->ID"
      );

Avatar
jam13

121 Posts

27 October 2007 at 11:30am

I do it like this:

$myFieldNames = array(
    'Options' => 'Options'
);
$myFieldTypes = array(
    'Options' => new DropdownField('Options','Options',array(
            '' => '',
            'Option 1' => 1,
            'Option 2' => 2,
            'Option 3' => 3
    ))
);
$myTableField = new TableField('MyTable', 'MyTable', $myFieldNames, $myFieldTypes, null, "ForeignID = {$this->ID}");

Whether that's the "right" way I'm not sure (it's the only way that I've got to work).

Avatar
Sigurd

Forum Moderator, 628 Posts

27 October 2007 at 1:33pm

Avatar
jam13

121 Posts

29 October 2007 at 5:23am

I think the confusion is (at least it confused me) that the TableField docs show how to pass an array of field types to create the table, which doesn't work with a more complex field like a dropdown. What it doesn't show is that you can pass it a FieldSet (as in the ComplexTableField docs).