hominid4
Member
I have a dropdown element, with the below query under the Eval Populate of the Advanced tab to build the dropdown. It works as needed except the 0 in the `label` column shows as "1" within the form, so the dropdown shows as:
1
1
2
I've been messing with this a good while and not sure how to prevent that, would anyone have a suggestion where the 0 label comes over as 0?
Thanks!
my_table
id | label (TEXT)
1 | 0
2 | 1
3 | 2
1
1
2
I've been messing with this a good while and not sure how to prevent that, would anyone have a suggestion where the 0 label comes over as 0?
Thanks!
my_table
id | label (TEXT)
1 | 0
2 | 1
3 | 2
PHP:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery = 'SELECT id, label FROM my_table';
$myDb->setQuery($myQuery);
$items = $myDb->loadObjectList();
$options[] = JHTML::_('select.option', '', 'Please select');
foreach ($items as $item) {
$options[] = JHTML::_('select.option', $item->id, $item->label);
}
return $options;
Last edited: