Improved <label> patch: got rid of ID's by implicit association, and made radio/check labels non-bold again.

4.4.x
Steven Wittens 2004-02-24 20:22:45 +00:00
parent bb82569cee
commit eadfa19239
2 changed files with 15 additions and 4 deletions

View File

@ -966,20 +966,28 @@ 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]\" id=\"edit-$name-$value\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />'. (!is_null($title) ? " <label for=\"edit-$name-$value\">$title</label>" : ''), $description);
$element = "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />';
if (!is_null($title)) {
$element = "<label class=\"option\">$element $title</label>";
}
return theme('form_element', NULL, $element, $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]\" id=\"edit-$name-$key\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> <label for=\"edit-$name-$key\">$choice</label><br />";
$choices .= "<label class=\"option\"><input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> $choice</label><br />";
}
return theme("form_element", $title, $choices, $description);
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]\" id=\"edit-$name\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />' . (!is_null($title) ? " <label for=\"edit-$name\">$title</label>" : ''), $description);
$element = "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" id=\"edit-$name\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />';
if (!is_null($title)) {
$element = "<label class=\"option\">$element $title</label>";
}
return form_hidden($name, 0) . theme('form_element', NULL, $element, $description);
}
function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL) {

View File

@ -150,6 +150,9 @@ li a.active {
.form-item label {
font-weight: bold;
}
.form-item label.option {
font-weight: normal;
}
.form-submit {
margin: 0.5em 0;
}