Part of the EllisLab Network

Bug Report

validation class set_select and multiple select in form

Date: 08/17/2007 Severity: Minor
Status: Bogus Reporter: Zacharias Knudsen
Version: 1.5.4
Keywords: Libraries, Validation Class
Forum Thread: http://codeigniter.com/forums/viewthread/49779/

Description

Here is a little update to set_select method of Validation class, which adds functionality when using multiple select in a form

Code Sample

function set_select($field = '', $value = '')
    
{
        
if ($field == '' OR $value == '' OR  ! isset($_POST[$field]))
        
{
            
return '';
        
}
        
        
if (is_array($_POST[$field])) {
            
if (in_array($value, $_POST[$field])) {
                
return ' selected="selected"';
            
} else {
                
return '';
            
}
        }
else {
            
if ($_POST[$field] == $value)
            
{
                
return ' selected="selected"';
            
}
        }
    }

Expected Result

Actual Result

Comment on Bug Report

Page 1 of 1 pages
Posted by: Derek Jones on 17 August 2007 8:12am
Derek Jones's avatar

Thank you for the code contribution, but as the current code does what it is intended and describes it to do, this would be more appropriate as a feature request.

Posted by: Zacharias Knudsen on 17 August 2007 9:33am
Zacharias Knudsen's avatar

Ah, yes. will do.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?