diff options
Diffstat (limited to 'system/helpers/form_helper.php')
-rw-r--r-- | system/helpers/form_helper.php | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 200da8ac5..692909c79 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -228,7 +228,7 @@ if ( ! function_exists('form_upload')) */ function form_upload($data = '', $value = '', $extra = '') { - $default = array('type' => 'file', 'name' => ''); + $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; return '<input '._parse_form_attributes($data, $defaults).$extra." />\n"; @@ -642,37 +642,14 @@ if ( ! function_exists('set_value')) */ function set_value($field = '', $default = '', $is_textarea = FALSE) { - if (FALSE !== ($OBJ =& _get_validation_object()) && $OBJ->has_rule($field)) - { - return form_prep($OBJ->set_value($field, $default), $is_textarea); - } - - // We couldn't find the $field in validator, so try in $_POST array - $index = $field; - $container = $_POST; - - // Test if the $field is an array name, and try to obtain the final index - if (preg_match_all('/\[(.*?)\]/', $field, $matches)) + if (FALSE === ($OBJ =& _get_validation_object())) { - sscanf($field, '%[^[][', $index); - for ($i = 0, $c = count($matches[0]); $i < $c; $i++) - { - if (isset($container[$index]) && $matches[1][$i] !== '') - { - $container = $container[$index]; - $index = $matches[1][$i]; - } - else - { - $container = array(); - break; - } - } + return isset($_POST[$field]) + ? form_prep($_POST[$field], $is_textarea) + : form_prep($default, $is_textarea); } - return isset($container[$index]) - ? form_prep($container[$index], $is_textarea) - : form_prep($default, $is_textarea); + return form_prep($OBJ->set_value($field, $default), $is_textarea); } } |