Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_radios checked problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
rhosoi
Smarty n00b


Joined: 17 Jun 2004
Posts: 1
Location: Mountain View, CA

PostPosted: Thu Jun 17, 2004 8:23 am    Post subject: html_radios checked problem Reply with quote

Hi, I found a small problem in the function html_radios.

.tpl
Code:
{html_radios name="mode" options=$modes selected=$mode}


.php
Code:
$smarty->assign("modes", array('0'=>'none','R'=>'Read','W'=>'Write'));

$mode = 'W';
$smarty->assign("mode", $mode);


Output
Code:
<label><input type="radio" name="mode" value="0" checked="checked" /></label>
<label><input type="radio" name="mode" value="R" /></label>
<label><input type="radio" name="mode" value="W" checked="checked" /></label>


the smarty checked radio button twice Shocked

this bug based on php auto type convert specification.
(0=='W') is true
because the types are converted to integer, not to string.

here is easy patch, you can apply to plugins/function.html_radios.php
Code:
128c128
-    if ($value==$selected) {
+    if ((string)$value==(string)$selected) {
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP