CI_Form_validation::set_select PHP Method

set_select() public method

Enables pull-down lists to be set to the value the user selected in the event of an error
public set_select ( $field = '', $value = '', $default = FALSE ) : string
return string
    public function set_select($field = '', $value = '', $default = FALSE)
    {
        if (!isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) {
            return $default === TRUE && count($this->_field_data) === 0 ? ' selected="selected"' : '';
        }
        $field = $this->_field_data[$field]['postdata'];
        $value = (string) $value;
        if (is_array($field)) {
            // Note: in_array('', array(0)) returns TRUE, do not use it
            foreach ($field as &$v) {
                if ($value === $v) {
                    return ' selected="selected"';
                }
            }
            return '';
        } elseif ($field === '' or $value === '' or $field !== $value) {
            return '';
        }
        return ' selected="selected"';
    }