summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2013-09-13 15:21:31 +0200
committerAndrey Andreev <narf@devilix.net>2013-09-13 15:21:31 +0200
commit67f6a5e0321cc5d71dc2adc8dc72c71e96408dac (patch)
tree570b350bf92df05453e556870911e319212b56fa /system/helpers
parentae50f5537718431af05037c857d1c303e25a76f6 (diff)
Fix array notation fields for set_select() as well
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/form_helper.php35
1 files changed, 8 insertions, 27 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 424bb7e64..20379efa7 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -675,37 +675,18 @@ if ( ! function_exists('set_select'))
*/
function set_select($field = '', $value = '', $default = FALSE)
{
- $OBJ =& _get_validation_object();
+ $CI =& get_instance();
- if ($OBJ === FALSE)
+ if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field))
{
- if ( ! isset($_POST[$field]))
- {
- if (count($_POST) === 0 && $default === TRUE)
- {
- return ' selected="selected"';
- }
- return '';
- }
-
- $field = $_POST[$field];
-
- if (is_array($field))
- {
- if ( ! in_array($value, $field))
- {
- return '';
- }
- }
- elseif (($field == '' OR $value == '') OR $field !== $value)
- {
- return '';
- }
-
- return ' selected="selected"';
+ return $CI->form_validation->set_select($field, $value, $default);
+ }
+ elseif (($input = $CI->input->post($field, FALSE)) === NULL)
+ {
+ return ($default === TRUE) ? ' selected="selected"' : '';
}
- return $OBJ->set_select($field, $value, $default);
+ return ($input === $value) ? ' checked="selected"' : '';
}
}