Invalid suboptions in drop down

Deeplogica

New Member
Hi
I am trying to load a dropdown list with data from a table using the following code

$options = JHTML::_('select.option', '0', 'Please select' );
$db = JFactory::getDbo();
$db->setQuery("SELECT ID, project_name, assessment_number FROM projects");
$rows = $db -> loadObjectList();
foreach ($rows as $row) {
$options = JHTML::_('select.option',(string) $row->ID, $row->project_name .' ' .$row->assessment_number);

}
return $options;

But I get the error stating
**Invalid suboptions specified for element 'project': stdClass::__set_state(array( 'value' => '2', 'text' => 'Walmart_Project1 2', 'disable' => false, ))**

Can anyone help please? I dont know what could be causing this

thanks
 
Are you using the "assessment_number" for extra information in dropdown list. If so, then, you can use databasejoin element and concat label "project_name" with "assessment_number".
 
ok, I just tried that.. and get the same error. It looks like there is something expected after the Disable-false but I cant see what.


this is my new code
$options = JHTML::_('select.option', '0', 'Please select' );
$db = JFactory::getDbo();
$db->setQuery("SELECT id, concat(project_name,' ', assessment_number) as project FROM projects");
$rows = $db -> loadObjectList();
foreach ($rows as $row) {
$options = JHTML::_('select.option', $row->id, $row->project);

}
return $options;
 
Need to look more carefully in the example:
$options[] = JHTML::_('select.option', $row->id, $row->text);
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top