Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.368
diff -u -p -r1.368 form.inc
--- includes/form.inc	29 Aug 2009 16:30:14 -0000	1.368
+++ includes/form.inc	1 Sep 2009 03:47:52 -0000
@@ -1494,6 +1494,25 @@ function form_options_flatten($array, $r
 }
 
 /**
+ * Return an attribute string if a form element's title should be output
+ * as a title attribute.
+ * 
+ * @param $element
+ *   An associative array containing the properties of the element.
+ *   Properties used: #title, #value, #options, #description, #extra, #multiple,
+ *   #required, #name, #attributes, #size.
+ * @return
+ *   A string " title=" and the element #title if #show_title is set to
+ *   FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE, otherwise an empty string. 
+ */
+function form_element_title_attribute($element) {
+  if (!empty($element['#title']) && isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE) {
+    return ' title="' . $element['#title'] . '"';
+  }
+  return '';
+}
+
+/**
  * Theme select form element.
  *
  * @param $element
@@ -1514,7 +1533,7 @@ function theme_select($element) {
   $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
   _form_set_class($element, array('form-select'));
   $multiple = $element['#multiple'];
-  return '<select name="' . $element['#name'] . '' . ($multiple ? '[]' : '') . '"' . ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) . ' id="' . $element['#id'] . '" ' . $size . '>' . form_select_options($element) . '</select>';
+  return '<select name="' . $element['#name'] . ($multiple ? '[]' : '') . '"' . ($multiple ? ' multiple="multiple"' : '') . form_element_title_attribute($element) . drupal_attributes($element['#attributes']) . ' id="' . $element['#id'] . '" ' . $size . '>' . form_select_options($element) . '</select>';
 }
 
 /**
@@ -1656,13 +1675,11 @@ function theme_radio($element) {
   _form_set_class($element, array('form-radio'));
   $output = '<input type="radio" ';
   $output .= 'id="' . $element['#id'] . '" ';
-  $output .= 'name="' . $element['#name'] . '" ';
+  $output .= 'name="' . $element['#name'] . '"';
+  $output .= form_element_title_attribute($element) . ' ';
   $output .= 'value="' . $element['#return_value'] . '" ';
   $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
   $output .= drupal_attributes($element['#attributes']) . ' />';
-  if (!is_null($element['#title'])) {
-    $output = '<label class="option" for="' . $element['#id'] . '">' . $output . ' ' . $element['#title'] . '</label>';
-  }
 
   return $output;
 }
@@ -1993,15 +2010,12 @@ function theme_checkbox($element) {
   $checkbox = '<input ';
   $checkbox .= 'type="checkbox" ';
   $checkbox .= 'name="' . $element['#name'] . '" ';
-  $checkbox .= 'id="' . $element['#id'] . '" ' ;
+  $checkbox .= 'id="' . $element['#id'] . '"';
+  $checkbox .= form_element_title_attribute($element) . ' ';
   $checkbox .= 'value="' . $element['#return_value'] . '" ';
   $checkbox .= $element['#value'] ? ' checked="checked" ' : ' ';
   $checkbox .= drupal_attributes($element['#attributes']) . ' />';
 
-  if (!is_null($element['#title'])) {
-    $checkbox = '<label class="option" for="' . $element['#id'] . '">' . $checkbox . ' ' . $element['#title'] . '</label>';
-  }
-
   return $checkbox;
 }
 
@@ -2437,7 +2451,7 @@ function theme_textfield($element) {
     $output .= '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ';
   }
 
-  $output .= '<input type="text"' . $maxlength . ' name="' . $element['#name'] . '" id="' . $element['#id'] . '"' . $size . ' value="' . check_plain($element['#value']) . '"' . drupal_attributes($element['#attributes']) . ' />';
+  $output .= '<input type="text"' . form_element_title_attribute($element) . $maxlength . ' name="' . $element['#name'] . '" id="' . $element['#id'] . '"' . $size . ' value="' . check_plain($element['#value']) . '"' . drupal_attributes($element['#attributes']) . ' />';
 
   if (isset($element['#field_suffix'])) {
     $output .= ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>';
@@ -2476,7 +2490,6 @@ function theme_form($element) {
  */
 function theme_textarea($element) {
   $class = array('form-textarea');
-
   // Add resizable behavior
   if ($element['#resizable'] !== FALSE) {
     drupal_add_js('misc/textarea.js');
@@ -2484,7 +2497,7 @@ function theme_textarea($element) {
   }
 
   _form_set_class($element, $class);
-  return '<textarea cols="' . $element['#cols'] . '" rows="' . $element['#rows'] . '" name="' . $element['#name'] . '" id="' . $element['#id'] . '" ' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
+  return '<textarea cols="' . $element['#cols'] . '" rows="' . $element['#rows'] . '" name="' . $element['#name'] . '" id="' . $element['#id'] . '"' . form_element_title_attribute($element) . ' ' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
 }
 
 /**
@@ -2518,9 +2531,8 @@ function theme_markup($element) {
 function theme_password($element) {
   $size = $element['#size'] ? ' size="' . $element['#size'] . '" ' : '';
   $maxlength = $element['#maxlength'] ? ' maxlength="' . $element['#maxlength'] . '" ' : '';
-
   _form_set_class($element, array('form-text'));
-  $output = '<input type="password" name="' . $element['#name'] . '" id="' . $element['#id'] . '" ' . $maxlength . $size . drupal_attributes($element['#attributes']) . ' />';
+  $output = '<input type="password" name="' . $element['#name'] . '" id="' . $element['#id'] . '" ' . form_element_title_attribute($element) . $maxlength . $size . drupal_attributes($element['#attributes']) . ' />';
   return $output;
 }
 
@@ -2554,7 +2566,7 @@ function form_process_weight($element) {
  */
 function theme_file($element) {
   _form_set_class($element, array('form-file'));
-  return '<input type="file" name="' . $element['#name'] . '"' . ($element['#attributes'] ? ' ' . drupal_attributes($element['#attributes']) : '') . ' id="' . $element['#id'] . '" size="' . $element['#size'] . "\" />\n";
+  return '<input type="file" name="' . $element['#name'] . '"' . form_element_title_attribute($element) . ' ' . ($element['#attributes'] ? ' ' . drupal_attributes($element['#attributes']) : '') . ' id="' . $element['#id'] . '" size="' . $element['#size'] . "\" />\n";
 }
 
 /**
@@ -2584,17 +2596,31 @@ function theme_form_element($element) {
   $output = '<div class="' . implode(' ', $class) . '">' . "\n";
   $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : '';
 
-  if (!empty($element['#title']) && empty($element['#form_element_skip_title'])) {
+  $label = '';
+
+  if (!empty($element['#title'])) {
     $title = $element['#title'];
     if (!empty($element['#id'])) {
-      $output .= ' <label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
+      $label = ' <label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
     }
     else {
-      $output .= ' <label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
+      $label= ' <label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n";
     }
   }
 
-  $output .= " " . $element['#children'] . "\n";
+  if ($element['#type'] == 'item') {
+    $output .= '<h3>' . $element['#title'] . '</h3>';
+  }
+
+  if (isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_BEFORE) {
+    $output .= $label . " " . $element['#children'] . "\n";
+  }
+  else if (isset($element['#show_title']) && $element['#show_title'] == FORM_ELEMENT_SHOW_TITLE_AFTER) {
+    $output .= $element['#children'] . " " . $label . "\n";
+  }
+  else {
+    $output .= " " . $element['#children'] . "\n";
+  }
 
   if (!empty($element['#description'])) {
     $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.61
diff -u -p -r1.61 system.css
--- modules/system/system.css	24 Aug 2009 03:11:34 -0000	1.61
+++ modules/system/system.css	1 Sep 2009 03:47:52 -0000
@@ -139,7 +139,9 @@ tr.merge-up, tr.merge-up td, tr.merge-up
   display: block;
   font-weight: bold;
 }
-.form-item label.option {
+.form-item label.option,
+.form-type-checkbox label,
+.form-type-radio label {
   display: inline;
   font-weight: normal;
 }
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.783
diff -u -p -r1.783 system.module
--- modules/system/system.module	31 Aug 2009 17:06:10 -0000	1.783
+++ modules/system/system.module	1 Sep 2009 03:47:52 -0000
@@ -88,6 +88,25 @@ define('REGIONS_ALL', 'all');
 
 
 /**
+ *
+ * Output form element titles as labels before form elements. @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_BEFORE', 'before');
+
+/**
+ *
+ * Output form element titles as labels after form elements. @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_AFTER', 'after');
+
+/**
+ *
+ * Output form element titles as the title attribute of form elements. @see system_elements().
+ */
+define('FORM_ELEMENT_SHOW_TITLE_ATTRIBUTE', 'attribute');
+
+
+/**
  * Implement hook_help().
  */
 function system_help($path, $arg) {
@@ -341,6 +360,7 @@ function system_elements() {
     '#process' => array('form_process_text_format', 'ajax_process_form'),
     '#theme' => 'textfield',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['password'] = array(
@@ -350,12 +370,14 @@ function system_elements() {
     '#process' => array('ajax_process_form'),
     '#theme' => 'password',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['password_confirm'] = array(
     '#input' => TRUE,
     '#process' => array('form_process_password_confirm'),
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['textarea'] = array(
@@ -366,6 +388,7 @@ function system_elements() {
     '#process' => array('form_process_text_format', 'ajax_process_form'),
     '#theme' => 'textarea',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['radios'] = array(
@@ -373,6 +396,7 @@ function system_elements() {
     '#process' => array('form_process_radios'),
     '#theme_wrappers' => array('radios'),
     '#pre_render' => array('form_pre_render_conditional_form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['radio'] = array(
@@ -381,7 +405,7 @@ function system_elements() {
     '#process' => array('ajax_process_form'),
     '#theme' => 'radio',
     '#theme_wrappers' => array('form_element'),
-    '#form_element_skip_title' => TRUE,
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_AFTER,
   );
 
   $type['checkboxes'] = array(
@@ -390,6 +414,7 @@ function system_elements() {
     '#process' => array('form_process_checkboxes'),
     '#theme_wrappers' => array('checkboxes'),
     '#pre_render' => array('form_pre_render_conditional_form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['checkbox'] = array(
@@ -398,7 +423,7 @@ function system_elements() {
     '#process' => array('ajax_process_form'),
     '#theme' => 'checkbox',
     '#theme_wrappers' => array('form_element'),
-    '#form_element_skip_title' => TRUE,
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_AFTER,
   );
 
   $type['select'] = array(
@@ -408,6 +433,7 @@ function system_elements() {
     '#process' => array('ajax_process_form'),
     '#theme' => 'select',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['weight'] = array(
@@ -423,6 +449,7 @@ function system_elements() {
     '#process' => array('form_process_date'),
     '#theme' => 'date',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['file'] = array(
@@ -430,6 +457,7 @@ function system_elements() {
     '#size' => 60,
     '#theme' => 'file',
     '#theme_wrappers' => array('form_element'),
+    '#show_title' => FORM_ELEMENT_SHOW_TITLE_BEFORE,
   );
 
   $type['tableselect'] = array(
