add a warning when an array is passed as the 'checked' value of html_radios

This commit is contained in:
mohrt
2003-03-19 22:52:22 +00:00
parent 8c73efec74
commit 35973b2231
2 changed files with 28 additions and 22 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- added warning message when an array is passed as
the "checked" value of html_radios (Monte)
- fixed errormessage in _compile_smarty_ref() (messju) - fixed errormessage in _compile_smarty_ref() (messju)
- updated docs for html_image "name" -> "file" (messju) - updated docs for html_image "name" -> "file" (messju)
- fixed bug with html_options-optgroups (Nichlas L<>fdahl, messju) - fixed bug with html_options-optgroups (Nichlas L<>fdahl, messju)

View File

@@ -25,7 +25,7 @@
function smarty_function_html_radios($params, &$smarty) function smarty_function_html_radios($params, &$smarty)
{ {
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
$name = 'radio'; $name = 'radio';
$values = null; $values = null;
$options = null; $options = null;
@@ -35,32 +35,36 @@ function smarty_function_html_radios($params, &$smarty)
$extra = ''; $extra = '';
foreach($params as $_key => $_val) { foreach($params as $_key => $_val) {
switch($_key) { switch($_key) {
case 'name': case 'name':
case 'separator': case 'separator':
case 'checked': case 'checked':
$$_key = (string)$_val; if(is_array($_val)) {
break; $smarty->trigger_error('the "checked"-attribute cannot be an array.', E_USER_WARNING);
} else {
$$_key = (string)$_val;
}
break;
case 'options': case 'options':
$$_key = (array)$_val; $$_key = (array)$_val;
break; break;
case 'values': case 'values':
case 'output': case 'output':
$$_key = array_values((array)$_val); $$_key = array_values((array)$_val);
break; break;
case 'radios': case 'radios':
$smarty->trigger_error('the use of the "radios"-attribute is deprecated. use "options" instead', E_USER_WARNING); $smarty->trigger_error('the use of the "radios"-attribute is deprecated. use "options" instead', E_USER_WARNING);
$options = (array)$_val; $options = (array)$_val;
break; break;
default: default:
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"'; $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars((string)$_val).'"';
break; break;
} }
} }
if (!isset($options) && !isset($values)) if (!isset($options) && !isset($values))