I wanted to show list as input field of joomla and options should be from other table. I also need one static opition like ALL. WHAT I Have to do ? I am using joomla 3.6 latest. I am asking fod multi select option combobox so admin can select One Multiple or None. Can anyone suggest about it.

  • 1
    You will probably need to provide a bit more context before you'll get a suitable answer. Nov 23, 2016 at 5:02
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking as it has nothing to do with Joomla. See the Asking section in Help Center for help clarifying your question.
    – Mikan
    Nov 23, 2016 at 8:49

1 Answer 1


There are a few ways that you can approach this issue. I'll assume that you have your database tables and relations setup.

This is what I would do:

1) Create a field type called 'country'. You create a 'country.php' file in the \models\fields\ directory:

defined("_JEXEC") or die("Restricted access");

class JFormFieldCountry extends JFormFieldList
    protected $type = 'country';

    protected function getOptions()
        $db = JFactory::getDbo();
        $options = array();

        $query = $db->getQuery(true);

        /** Assumes that the table has fields -> id, country, country_addrev **/
        $query->select($db->quoteName(array('id', 'country', 'country_abbrev')))
              ->where($db->quoteName('id') . ' > 0');


        foreach ($db->loadObjectList() as $item)
            // Create a new option object based on the <option /> element.
            $tmp = JHtml::_('select.option', $item->id, $item->name);

            // Add the option object to the result set.
            $options[] = $tmp;

        // Merge any additional options in the XML definition.
        $options = array_merge(parent::getOptions(), $options);

        return $options;

2) In the form that I needed the drop-down list box I would have:

    description="My field description"
    <option value=""></option>

That will give you the drop-down list box you desire.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.