select.genericlist simulate a multiple combobox

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
vandana
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Fri Jun 27, 2008 1:14 pm

select.genericlist simulate a multiple combobox

Postby vandana » Sun Jul 27, 2008 11:33 am

I have a combobox in joomla where you can select multiple values with holding the CTRL-key.
Now I want to see the selected values in the combobox when I edit that record.

I have a group. And in this group you can add multiple groupmembers/users.
My combobox code looks like this:

$query = "SELECT groupmember_id as value, groupmember_name as text FROM jos_groupmembers";
$db->setQuery( $query );
$rowsGroupMembers = $db->loadObjectList();
$mode = "";
if($this->_task == 'edit'){
$rowsGroupMembers['groupmember_name'] = JHTML::_('select.genericlist',
$rowsGroupMembers, 'groupmember_id[]', 'size="10" multiple', 'value', 'text',
$row->groupmember_id);

$mode = "edit";

} else{
$rowsGroupMembers['groupmember_name'] = JHTML::_('select.genericlist',
$rowsGroupMembers, 'groupmember_id[]', ' size="10" multiple' );
$mode = "add";
}

It is more about the edit part. How can I select the groupmembers from that group.
For example I have 4 users is my combobox but the first two are in the group. So when I edit that group I want to see the 4 groupmembers, but only the first two should be selected. How to do this in Joomla?

Vandana

vandana
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Fri Jun 27, 2008 1:14 pm

Re: select.genericlist simulate a multiple combobox

Postby vandana » Sun Jul 27, 2008 12:37 pm

Hi

I found the solution.

$rowsGroupMembers['groupmember_name'] = JHTML::_('select.genericlist', $rowsGroupMembers, 'groupmember_id[]', 'size="10" multiple', 'value', 'text', $rowsSelected);

$rowsSelected is the array of the selected members.
$rowsGroupMembers is the array with all the members

Vandana


Return to “Joomla! Coding 101”

Who is online

Users browsing this forum: No registered users and 1 guest