diff options
author | Andrey Andreev <narf@devilix.net> | 2013-10-23 18:57:46 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2013-10-23 18:57:46 +0200 |
commit | a587a939ce0b8e7d1dfe0830ac83d881e151d6e0 (patch) | |
tree | 8ee3579bd062508cb202b3ab8314b7ffe70ebc30 /system/helpers/form_helper.php | |
parent | 6614367f62d2cbd9e8f979c9349cd5474b035866 (diff) |
Fix issue #2695
Diffstat (limited to 'system/helpers/form_helper.php')
-rw-r--r-- | system/helpers/form_helper.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 400a91faa..a3d299b0d 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -682,9 +682,20 @@ if ( ! function_exists('set_select')) { return ($default === TRUE) ? ' selected="selected"' : ''; } - elseif (is_array($input) && in_array($value, $input, TRUE)) + + $value = (string) $value; + if (is_array($input)) { - return ' selected="selected"'; + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($input as &$v) + { + if ($value === $v) + { + return ' selected="selected"'; + } + } + + return ''; } return ($input === $value) ? ' selected="selected"' : ''; @@ -718,9 +729,20 @@ if ( ! function_exists('set_checkbox')) { return ($default === TRUE) ? ' checked="checked"' : ''; } - elseif (is_array($input) && in_array($value, $input, TRUE)) + + $value = (string) $value; + if (is_array($input)) { - return ' checked="checked"'; + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($input as &$v) + { + if ($value === $v) + { + return ' checked="checked"'; + } + } + + return ''; } return ($input === $value) ? ' checked="checked"' : ''; @@ -755,7 +777,7 @@ if ( ! function_exists('set_radio')) return ($default === TRUE) ? ' checked="checked"' : ''; } - return ($input === $value) ? ' checked="checked"' : ''; + return ($input === (string) $value) ? ' checked="checked"' : ''; } } |