17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1591 Views |
-
TableField Dropdown

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"
); -
Re: TableField Dropdown

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).
-
Re: TableField Dropdown

27 October 2007 at 1:33pm
Its the same as http://doc.silverstripe.com/doku.php?id=optionsetfield
-
Re: TableField Dropdown

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).
| 1591 Views | ||
|
Page:
1
|
Go to Top |


