Fieldtype

Archived
Forum
(read-only)

VZ Members

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Eli Van Zoeren

     

It is possible to save only one member in multiselect

Bug Report

Laisvunas
Laisvunas

Hi Eli,

I spotted a bug in the version 1.0.6. It is possible to save only one member in multiselect. E.g. if I select two members in multiselect, only one member is being saved.

I fixed this bug by changing the code of the file ft.vz_members.php in 2 places.

1. The lines 237-269

if ($mode == 'single' || $mode == 'multiselect')
        
{
            
// Get the first selected member if there are more than one
            
if ($mode == 'single')
            
{
              $selected_members 
array_shift($selected_members);
            
}

            
// Construct the select box markup
            
$r '<select name="' $field_name . ($mode == 'multiselect' '[]' '') .'"';
            
$r .= $mode == 'multiselect' ' size="10" multiple="multiple"' '';
            
$r .= '><option value=""' . ((!$selected_members OR !count($selected_members)) ? ' selected="selected"' '') . '>&mdash;</option>' NL;
            foreach (
$members as $member)
            
{
                
// If we are moving on to a new group
                
if ($current_group != $member['group_id'])
                
{
                    
// Output the group header
                    
if ($current_group$r .= '</optgroup>' NL;
                    
$r .= '<optgroup label="'.$member['group_title'].'">' NL;

                    
// Set the new current group
                    
$current_group $member['group_id'];
                
}

                
// Output the option
                
$r .= '<option value="' $member['member_id''"'
                    
. (($member['member_id'== $selected_members OR in_array($member['member_id']$selected_members)) ? ' selected="selected"' '') . '>'
                    
$member['screen_name''</option>' NL;
            
}
            $r 
.= '</optgroup>';
            
$r .= '</select>';
        

2. The lines 330-340:

function save($field_data)
    
{
        
// Remove the temporary element
        
if (is_array($field_data))
        
{
           
//@array_pop($field_data);
           
$field_data implode('|'$field_data);
        
}
        
return $field_data;
    
Eli Van Zoeren
# 1
Developer
Eli Van Zoeren

Thanks for the fix! I’ll get a new release out tomorrow with this code.

Eli Van Zoeren
# 2
Developer
Eli Van Zoeren

Your fix is included in the current version, 1.0.7. Thanks for the code.