I am trying to create a dropdown menu using a table to populate the dropdown selection options. The dropdown element appears on the form but it is blank. Here is my code, basically taken from the wiki example:
I ran the code in a little php script and verified that the $options array is populated:
etc.....
The sub-options under 'Data' have been left empty. I'm sure it's something basic that is preventing the sub-options from appearing, but I sure can't find it.
Code:
$options[] = JHTML::_('select.option', '0', 'Please select' );
$db = JFactory::getDbo();
$db->setQuery("SELECT id, region FROM oc_regions");
$rows = $db -> loadObjectList();
foreach ($rows as $row) {
$options[] = JHTML::_('select.option', $row->id, $row->region);
}
return $options;
I ran the code in a little php script and verified that the $options array is populated:
Code:
phpArray ( [0] => stdClass Object ( [value] => 0 [text] => Please select [disable] => ) [1] => stdClass Object ( [value] => 1 [text] => Red Rock [disable] => ) [2] => stdClass Object ( [value] => 2 [text] => Calgary [disable] => ) [3] => stdClass Object ( [value] => 3 [text] => PacNW [disable] => ) [4]
etc.....
The sub-options under 'Data' have been left empty. I'm sure it's something basic that is preventing the sub-options from appearing, but I sure can't find it.