04-22-2016, 06:21 AM
Since Codeigniter 3.xx or before the set_value method has changed.
I have this in MY_form_helper
function set_value($field = '', $default = ''){
if (FALSE === ($OBJ =& _get_validation_object()))
{
if (isset($_POST[$field]))
{
return form_prep($_POST[$field], $field);
}
if(isset($_GET[field]))
{
return form_prep($_GET[$field], $field);
}
return $default;
}
return form_prep($OBJ->set_value($field, $default), $field);
}
In Codeigniter 3.xx it looks like this
function set_value($field, $default = '', $html_escape = TRUE)
{
$CI =& get_instance();
$value = (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
? $CI->form_validation->set_value($field, $default)
: $CI->input->post($field, FALSE);
isset($value) OR $value = $default;
return ($html_escape) ? html_escape($value) : $value;
}
can anybody help me rewrite it so it fixes my the get problem for my search input? and does the same as my prev code?
THX
ALOT
I have this in MY_form_helper
function set_value($field = '', $default = ''){
if (FALSE === ($OBJ =& _get_validation_object()))
{
if (isset($_POST[$field]))
{
return form_prep($_POST[$field], $field);
}
if(isset($_GET[field]))
{
return form_prep($_GET[$field], $field);
}
return $default;
}
return form_prep($OBJ->set_value($field, $default), $field);
}
In Codeigniter 3.xx it looks like this
function set_value($field, $default = '', $html_escape = TRUE)
{
$CI =& get_instance();
$value = (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
? $CI->form_validation->set_value($field, $default)
: $CI->input->post($field, FALSE);
isset($value) OR $value = $default;
return ($html_escape) ? html_escape($value) : $value;
}
can anybody help me rewrite it so it fixes my the get problem for my search input? and does the same as my prev code?
THX
