I try for a while to understand how can I add selected option to my dropdownlist my code looks as it follows. I create an option array than I genrate the list, on the next step I check if already has the a filed a selected option if yes I would like show as <option value = "my_value" selected="my_selected">My selected</option>
The code above won't do that
public function getInput() {
$spec_fields = array();
$jinput = JFactory::getApplication()->input;
$id = $jinput->get('id');
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from('#__immobilien_cat')
->order('cat_name');
$db->setQuery($query);
$rows = $db->loadObjectList();
if (isset($id)) {
$query = $db->getQuery(true)
->select('
cat.id,cat.cat_name')
->from('#__imobillien AS immo')
->join('LEFT', '#__immobilien_cat AS cat ON immo.category_id =
cat.id')
->where('
immo.id = ' . $id);
$db->setQuery($query);
$actual_row = $db->loadRow();
var_dump($actual_row[1]);
}
$options[] = JHTML::_('select.option','',JText::_('COM_IMMOS_SELECT_CAT'));
foreach ($rows as $key => $value) {
$options[] = JHTML::_('select.option', $value->id, JText::_($value->cat_name));
}
//return JHTML::_('select.genericlist', $options,'jform[category]', 'class="nourritures"','value','text',$actual_row[1]);
return JHTML::_('select.genericlist', $options, 'jform[category]', 'class = "nourritures"', 'value','text', 'Villa' );
}