strict comparason didn't work in all cases. use type-casting now.

This commit is contained in:
messju
2003-12-09 20:02:06 +00:00
parent aa2ee3cd66
commit a7c3e88d8f
2 changed files with 7 additions and 4 deletions

View File

@@ -73,7 +73,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
case 'checked': case 'checked':
case 'selected': case 'selected':
$selected = array_values((array)$_val); $selected = array_map('strval', array_values((array)$_val));
break; break;
case 'checkboxes': case 'checkboxes':
@@ -122,7 +122,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
. smarty_function_escape_special_chars($name) . '[]" value="' . smarty_function_escape_special_chars($name) . '[]" value="'
. smarty_function_escape_special_chars($value) . '"'; . smarty_function_escape_special_chars($value) . '"';
if (in_array($value, $selected, true)) { if (in_array((string)$value, $selected)) {
$_output .= ' checked="checked"'; $_output .= ' checked="checked"';
} }
$_output .= $extra . ' />' . $output; $_output .= $extra . ' />' . $output;

View File

@@ -48,11 +48,14 @@ function smarty_function_html_options($params, &$smarty)
$$_key = (array)$_val; $$_key = (array)$_val;
break; break;
case 'selected':
case 'values': case 'values':
case 'output': case 'output':
$$_key = array_values((array)$_val); $$_key = array_values((array)$_val);
break; break;
case 'selected':
$$_key = array_map('strval', array_values((array)$_val));
break;
default: default:
if(!is_array($_val)) { if(!is_array($_val)) {
@@ -95,7 +98,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
if(!is_array($value)) { if(!is_array($value)) {
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' . $_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
smarty_function_escape_special_chars($key) . '"'; smarty_function_escape_special_chars($key) . '"';
if (in_array($key, $selected, true)) if (in_array((string)$key, $selected))
$_html_result .= ' selected="selected"'; $_html_result .= ' selected="selected"';
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n"; $_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
} else { } else {