- Patch by Steven: added <label>s to checkboxes and radio buttons.

4.4.x
Dries Buytaert 2004-02-23 07:28:18 +00:00
parent 0c3707a0a7
commit 5b5f148ad4
1 changed files with 3 additions and 3 deletions

View File

@ -966,20 +966,20 @@ function form_group($legend, $group, $description = NULL) {
}
function form_radio($title, $name, $value = 1, $checked = 0, $description = NULL, $attributes = NULL) {
return theme("form_element", NULL, "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) ." /> $title", $description);
return theme("form_element", NULL, "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" id=\"edit-$name-$value\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />'. (!is_null($title) ? " <label for=\"edit-$name-$value\">$title</label>" : ''), $description);
}
function form_radios($title, $name, $value, $options, $description = NULL) {
if (count($options) > 0) {
foreach ($options as $key => $choice) {
$choices .= "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> $choice<br />";
$choices .= "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" id=\"edit-$name-$key\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> <label for=\"edit-$name-$key\">$choice</label><br />";
}
return theme("form_element", $title, $choices, $description);
}
}
function form_checkbox($title, $name, $value = 1, $checked = 0, $description = NULL, $attributes = NULL) {
return form_hidden($name, 0) . theme("form_element", NULL, "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) ." /> $title", $description);
return form_hidden($name, 0) . theme("form_element", NULL, "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" id=\"edit-$name\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />' . (!is_null($title) ? " <label for=\"edit-$name\">$title</label>" : ''), $description);
}
function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL) {