html_options

From: Date: Sat, 24 Feb 2007 18:39:05 +0000
Subject: html_options
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2966@lists.php.net to get a copy of this message
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)


« previous php.smarty.dev (#2966) next »