Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.272
diff -u -p -p -r1.272 form.inc
--- includes/form.inc	6 May 2008 12:18:45 -0000	1.272
+++ includes/form.inc	15 Jun 2008 04:14:13 -0000
@@ -1508,7 +1508,7 @@ function theme_fieldset($element) {
  *
  * @param $element
  *   An associative array containing the properties of the element.
- *   Properties used: required, return_value, value, attributes, title, description
+ *   Properties used: required, return_value, value, attributes, title, description, id
  * @return
  *   A themed HTML string representing the form item group.
  *
@@ -1519,10 +1519,22 @@ function theme_radio($element) {
   $output = '<input type="radio" ';
   $output .= 'name="' . $element['#name'] . '" ';
   $output .= 'value="' . $element['#return_value'] . '" ';
+  if (!empty($element['#id'])) {
+    $output .= 'id="' . $element['#id'] . '" ';
+  }
   $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
   $output .= drupal_attributes($element['#attributes']) . ' />';
   if (!is_null($element['#title'])) {
-    $output = '<label class="option">' . $output . ' ' . $element['#title'] . '</label>';
+    if (!empty($element['#id'])) {
+      // Using the 'for' attribute for the label allow the user
+      // to select the radio by clicking on the label text.
+      // IE6 requires the for attributes even though the
+      // W3C HTML 4.01 specifications says it is optionnal.
+      $output = '<label class="option" for="' . $element['#id'] . '">' . $output . ' ' . $element['#title'] . '</label>';
+    }
+    else {
+      $output = '<label class="option">' . $output . ' ' . $element['#title'] . '</label>';
+    }
   }
 
   unset($element['#title']);
@@ -1843,7 +1855,7 @@ function theme_item($element) {
  *
  * @param $element
  *   An associative array containing the properties of the element.
- *   Properties used:  title, value, return_value, description, required
+ *   Properties used:  title, value, return_value, description, required, attributes, id
  * @return
  *   A themed HTML string representing the checkbox.
  *
@@ -1854,13 +1866,24 @@ function theme_checkbox($element) {
   $checkbox = '<input ';
   $checkbox .= 'type="checkbox" ';
   $checkbox .= 'name="' . $element['#name'] . '" ';
-  $checkbox .= 'id="' . $element['#id'] . '" ' ;
+  if (!empty($element['#id'])) {
+    $checkbox .= 'id="' . $element['#id'] . '" ' ;
+  }
   $checkbox .= 'value="' . $element['#return_value'] . '" ';
   $checkbox .= $element['#value'] ? ' checked="checked" ' : ' ';
   $checkbox .= drupal_attributes($element['#attributes']) . ' />';
 
   if (!is_null($element['#title'])) {
-    $checkbox = '<label class="option">' . $checkbox . ' ' . $element['#title'] . '</label>';
+    if (!empty($element['#id'])) {
+      // Using the 'for' attribute for the label allow the user
+      // to select the radio by clicking on the label text.
+      // IE6 requires the for attributes even though the
+      // W3C HTML 4.01 specifications says it is optionnal.
+      $checkbox = '<label class="option" for="' . $element['#id'] . '">' . $checkbox . ' ' . $element['#title'] . '</label>';
+    }
+    else {
+      $checkbox = '<label class="option">' . $checkbox . ' ' . $element['#title'] . '</label>';
+    }
   }
 
   unset($element['#title']);
