0

How do I generate a dropdown list with custom item in joomla 3.1. I took a look on couple of examples but I don not get the thing to work. I have been trying the following but the list is not genarated the html works.

public function getInput() {
    $jinput = JFactory::getApplication()->input;
    $sub_id = $jinput->get('sub_id');
    $db = JFactory::getDbo();
    $query = $db->getQuery(true)
            ->select('*')
            ->from('#__unis_faculties')   
            ->order('faculty_name');
    $db->setQuery($query);
    $rows = $db->loadObjectList();



    //array_unshift($rows, JHtml::_('select.option', '', JText::_('COM_UNIS_FACULTIES'), 'value', 'text'));
    return JHTML::_('select.genericlist',$rows,'faculties',array('class'=>'nourritures','option.attr'=>'data'));

}
4

1 回答 1

0

Your code actually does not look to have problems.

As long as the query returns something you are on the right track.

  1. Change select('*') to select('COL_A as value, COL_B as text').

  2. Make sure you echo the result of the method getInput (not a great name btw, how about getFacultiesDropdown()

于 2013-07-14T08:05:23.577 回答