Html_radios with labels?

From: Date: Wed, 07 Jan 2004 08:58:44 +0000
Subject: Html_radios with labels?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10778@lists.php.net to get a copy of this message
Hi, html_radios with labels doesn't allow clicking on the labels (at least IE). The following smarty-created code doesn't work: <form action="index.php" method="get"> <label><input type="radio" name="filter" value="NY" />New York</label> <label><input type="radio" name="filter" value="NE" checked="checked" />Nebraska</label> <label><input type="radio" name="filter" value="KS" />Kansas</label> <label><input type="radio" name="filter" value="IA" />Iowa</label> <label><input type="radio" name="filter" value="OK" />Oklahoma</label> <label><input type="radio" name="filter" value="TX" />Texas</label> </form> It seems that at least IE need a <label for="id"> attribute to work correctly. I'm therefore suggesting the following change to add the 'for' and 'id' attributes: function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) { $_output = ''; if ($labels) $_output .= '<label for="'.smarty_function_escape_special_chars($name).smarty_function_escape_sp ecial_chars($value).'">'; $_output .= '<input type="radio" name="' . smarty_function_escape_special_chars($name) . '" id="' . smarty_function_escape_special_chars($name).smarty_function_escape_special_c hars($value) . '" value="' . smarty_function_escape_special_chars($value) . '"'; if ($value==$selected) { $_output .= ' checked="checked"'; } $_output .= $extra . ' />' . $output; if ($labels) $_output .= '</label>'; $_output .= $separator . "\n"; return $_output; } Andreas Goetz cpuidle@gmx.de http://www.cpuidle.de

« previous php.smarty.general (#10778) next »