Hey list,
User Sweetums recently asked on the IRC channel about a weird problem in
html_options. See this code snipet:
--- template ---
{html_options name=foo options=$myOptions selected=$mySelect}
--- .php ---
$smarty->assign('myOptions', array(true => 'test', false => 'foo'));
$smarty->assign('mySelect', false);
$smarty->display('test.tpl');
This will not select foo as default option because the boolean in select
is casted to a string (resulting in an empty string) but in options the
boolean is casted to an int (resulting in 0). This patch should fix it up:
Index: plugins/function.html_options.php
===================================================================
RCS file: /repository/smarty/libs/plugins/function.html_options.php,v
retrieving revision 1.25
diff -r1.25 function.html_options.php
58c58
< $$_key = array_map('strval', array_values((array)$_val));
---
> $$_key = $_val;
102c102
< if (in_array((string)$key, $selected))
---
> if ((string)$key == $selected)
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|