Re: [SMARTY] Html_radios with labels?

From: Date: Thu, 08 Jan 2004 13:02:10 +0000
Subject: Re: [SMARTY] Html_radios with labels?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10781@lists.php.net to get a copy of this message
On Wed, Jan 07, 2004 at 09:58:44AM +0100, Andreas Goetz wrote: > 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: OTOH the standard says the id is optional, but of course actual implementations may differ. a question to the list: is an id "$name_$value" unique enough, so that it does not interfere with other ids on the webpage? if so, we should add that id, IMHO. BTW: does html_checkboxes have the same problem? greetings messju > 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 > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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