wagner.nardin
New Member
Hi
I would like to use a dropdown element to choose Joomla user groups
I believe the best way would be to create a dropdown element and add PHP code to read the mysql table 'jos_usergroups', so I'm using the following steps.
Thanks.
I would like to use a dropdown element to choose Joomla user groups
I believe the best way would be to create a dropdown element and add PHP code to read the mysql table 'jos_usergroups', so I'm using the following steps.
- I'm creating a new element with the 'dropdown' option for the plugin field.
- On the Data tab I have empty sub-options and multiple selections marked as 'no'
- On the front end additions tab I have the fields: Enable, Only add label and Save new additions, marked as 'no'.
- On the Advanced tab, I have the separator field 'empty' and the Eval populate field with the code:
PHP:$db = JFactory::getDbo(); $db->setQuery('SELECT id, text FROM jos_usergroups'); $rows = $db->loadObjectList(); foreach ($rows as $row) { $options[] = JHTML::_('select.option', $row->id, $row->text); } return $options;
- On the formatting tab I have the Enhanced dropdown field marked as 'no' and the Bootstrap class with 'input-medium'.
- On the Options tab I have the Default option 'empty' and the Eval option checked as 'no'.
Thanks.