add label ids to html_radios

This commit is contained in:
mohrt
2005-02-24 14:37:48 +00:00
parent 626101b30a
commit 02a7c04d88
2 changed files with 8 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ INSTALL SMARTY LIBRARY FILES
Copy the Smarty library files to your system. In our example, we place them in
/usr/local/lib/php/Smarty/
$> cd YOUR_DOWNLOAD_DIRECTORY
$> gtar -ztvf Smarty-2.6.7.tar.gz
$> mkdir /usr/local/lib/php/Smarty
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty

View File

@@ -127,11 +127,16 @@ function smarty_function_html_radios($params, &$smarty)
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
$_output = '';
if ($labels) $_output .= '<label>';
if ($labels) {
$_id = smarty_function_escape_special_chars($name . '_' . $value);
$_output .= '<label for="' . $_id . '">';
}
$_output .= '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"';
if ($labels) $_output .= ' id="' . $_id . '"';
if ($value==$selected) {
$_output .= ' checked="checked"';
}