Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.29.2.15
diff -u -r1.29.2.15 date.inc
--- components/date.inc	17 Oct 2010 21:52:38 -0000	1.29.2.15
+++ components/date.inc	18 Oct 2010 06:21:50 -0000
@@ -124,14 +124,14 @@
     '#weight' => $component['weight'],
     '#type' => 'date',
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
     '#required' => $component['mandatory'],
     '#year_start' => $component['extra']['year_start'],
     '#year_end' => $component['extra']['year_end'],
     '#process' => array('webform_expand_date'),
     '#theme' => 'webform_date',
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#element_validate' => array('webform_validate_date'),
     '#webform_component' => $component,
   );
@@ -315,7 +315,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_date',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#format' => $format,
     '#value' => $value,
Index: components/email.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/email.inc,v
retrieving revision 1.28.2.7
diff -u -r1.28.2.7 email.inc
--- components/email.inc	17 Oct 2010 21:52:38 -0000	1.28.2.7
+++ components/email.inc	18 Oct 2010 06:21:50 -0000
@@ -116,10 +116,10 @@
     '#weight' => $component['weight'],
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
     '#attributes' => $component['extra']['attributes'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
     '#element_validate'  => array('_webform_validate_email'),
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
@@ -177,7 +177,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_email',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#format' => $format,
     '#value' => isset($value[0]) ? $value[0] : '',
Index: components/fieldset.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/fieldset.inc,v
retrieving revision 1.11.2.4
diff -u -r1.11.2.4 fieldset.inc
--- components/fieldset.inc	28 Sep 2010 22:43:55 -0000	1.11.2.4
+++ components/fieldset.inc	18 Oct 2010 06:21:50 -0000
@@ -60,8 +60,8 @@
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
     '#collapsible' => $component['extra']['collapsible'],
     '#collapsed' => $component['extra']['collapsed'],
-    '#attributes' => array('class' => 'webform-component-' . $component['type'], 'id' => 'webform-component-' . $component['form_key']),
-    '#pre_render' => array('webform_element_title_display'),
+    '#attributes' => array('class' => 'webform-component-' . $component['type']),
+    '#pre_render' => array('webform_fieldset_prerender', 'webform_element_title_display'),
     '#webform_component' => $component,
   );
 
@@ -69,6 +69,14 @@
 }
 
 /**
+ * Pre-render function to set a fieldset ID.
+ */
+function _webform_fieldset_prerender($element) {
+  $element['#attributes']['id'] = 'webform-component-' . implode('--', array_slice($element['#parents'], 1));
+  return $element;
+}
+
+/**
  * Implementation of _webform_display_component().
  */
 function _webform_display_fieldset($component, $value, $format = 'html') {
Index: components/file.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/file.inc,v
retrieving revision 1.17.2.10
diff -u -r1.17.2.10 file.inc
--- components/file.inc	17 Oct 2010 21:52:38 -0000	1.17.2.10
+++ components/file.inc	18 Oct 2010 06:21:50 -0000
@@ -303,7 +303,6 @@
     '#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
     '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
     //'#required' => $component['mandatory'], // Drupal core bug with required file uploads.
-    '#weight' => $component['weight'],
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
     '#attributes' => $component['extra']['attributes'],
     '#tree' => FALSE, // file_check_upload assumes a flat $_FILES structure.
@@ -318,9 +317,9 @@
   $element['#webform_form_key'] = $form_key;
   $element['#weight'] = $component['weight'];
   $element['#theme'] = 'webform_render_file';
-  $element['#prefix'] = '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">';
-  $element['#suffix'] = '</div>';
-
+  $element['#theme_wrappers'] = array('webform_element_wrapper');
+  $element['#post_render'] = array('webform_element_wrapper');
+  $element['#webform_component'] = $component;
 
   // Change the 'width' option to the correct 'size' option.
   if ($component['extra']['width'] > 0) {
@@ -358,7 +357,11 @@
     $element[$element['#webform_form_key']]['#required'] = TRUE;
   }
 
-  return drupal_render($element);
+  $output = '';
+  foreach (element_children($element) as $key) {
+    $output .= drupal_render($element[$key]);
+  }
+  return $output;
 }
 
 /**
@@ -501,7 +504,7 @@
      '#value' => $fid ? webform_get_file($fid) : NULL,
      '#weight' => $component['weight'],
      '#theme' => 'webform_display_file',
-     '#theme_wrappers' => $format == 'text' ? array('webform_element_text') : array('webform_element'),
+     '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
      '#post_render' => array('webform_element_wrapper'),
      '#webform_component' => $component,
      '#format' => $format,
Index: components/grid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/grid.inc,v
retrieving revision 1.14.2.13
diff -u -r1.14.2.13 grid.inc
--- components/grid.inc	17 Oct 2010 21:52:38 -0000	1.14.2.13
+++ components/grid.inc	18 Oct 2010 06:21:50 -0000
@@ -145,11 +145,11 @@
     '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
     '#required' => $component['mandatory'],
     '#weight' => $component['weight'],
-    '#theme' => 'webform_grid',
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
+    '#theme' => 'webform_grid',
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
@@ -203,14 +203,14 @@
     '#questions' => $questions,
     '#options' => $options,
     '#theme' => 'webform_display_grid',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#sorted' => TRUE,
     '#webform_component' => $component,
   );
 
   foreach ($questions as $key => $question) {
-    if ($question != '') {
+    if ($question !== '') {
       $element[$question] = array(
         '#title' => $question,
         '#value' => isset($value[$key]) ? $value[$key] : NULL,
@@ -238,7 +238,7 @@
       $row = array();
       $row[] = array('data' => _webform_filter_xss($element[$key]['#title']), 'class' => 'webform-grid-question');
       foreach ($element['#options'] as $option_value => $option_label) {
-        if ($option_value == $element[$key]['#value']) {
+        if (strcmp($option_value, $element[$key]['#value']) == 0) {
           $row[] = array('data' => '<strong>X</strong>', 'class' => 'checkbox webform-grid-option');
         }
         else {
Index: components/hidden.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/hidden.inc,v
retrieving revision 1.21.2.4
diff -u -r1.21.2.4 hidden.inc
--- components/hidden.inc	28 Sep 2010 22:43:55 -0000	1.21.2.4
+++ components/hidden.inc	18 Oct 2010 06:21:51 -0000
@@ -81,7 +81,7 @@
     '#theme' => 'webform_display_hidden',
     '#format' => $format,
     '#theme' => 'webform_display_hidden',
-    '#theme_wrappers' => $format == 'text' ? array('webform_element_text') : array('webform_element'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
Index: components/markup.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/markup.inc,v
retrieving revision 1.13.2.4
diff -u -r1.13.2.4 markup.inc
--- components/markup.inc	28 Sep 2010 22:43:56 -0000	1.13.2.4
+++ components/markup.inc	18 Oct 2010 06:21:51 -0000
@@ -50,13 +50,13 @@
  */
 function _webform_render_markup($component, $value = NULL, $filter = TRUE) {
   $element = array(
-    '#type'   => 'markup',
-    '#title'  => $filter ? _webform_filter_xss($component['name']) : $component['name'],
+    '#type' => 'markup',
+    '#title' => $filter ? NULL : $component['name'],
     '#weight' => $component['weight'],
     '#markup' => $filter ? _webform_filter_values(check_markup($component['value'], $component['extra']['format'], FALSE), NULL, NULL, NULL, FALSE) : $component['value'],
     '#input_format' => $component['extra']['format'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
+    '#theme_wrappers' => array('webform_element_wrapper'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
Index: components/select.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/select.inc,v
retrieving revision 1.39.2.25
diff -u -r1.39.2.25 select.inc
--- components/select.inc	18 Oct 2010 00:23:24 -0000	1.39.2.25
+++ components/select.inc	18 Oct 2010 06:21:51 -0000
@@ -263,7 +263,9 @@
     '#required' => $component['mandatory'],
     '#weight' => $component['weight'],
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
@@ -358,9 +360,6 @@
     }
   }
 
-  $element['#prefix'] = '<div class="webform-component webform-component-' . $element['#type'] . '" id="webform-component-' . $component['form_key'] . '">';
-  $element['#suffix'] = '</div>';
-
   return $element;
 }
 
@@ -456,7 +455,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_select',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#format' => $format,
     '#value' => (array) $value,
Index: components/textarea.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textarea.inc,v
retrieving revision 1.20.2.7
diff -u -r1.20.2.7 textarea.inc
--- components/textarea.inc	17 Oct 2010 21:52:38 -0000	1.20.2.7
+++ components/textarea.inc	18 Oct 2010 06:21:51 -0000
@@ -109,9 +109,9 @@
     '#cols' => !empty($component['extra']['cols']) ? $component['extra']['cols'] : 60,
     '#attributes' => $component['extra']['attributes'],
     '#resizable' => (bool) $component['extra']['resizable'], // MUST be FALSE to disable.
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
@@ -134,7 +134,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_textarea',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#format' => $format,
     '#value' => isset($value[0]) ? $value[0] : '',
@@ -150,7 +150,7 @@
   if (strlen($output) > 80) {
     $output = ($element['#format'] == 'html') ? '<div class="webform-long-answer">' . $output . '</div>' : $output;
   }
-  return $value !== '' ? $output : ' ';
+  return $output !== '' ? $output : ' ';
 }
 
 /**
Index: components/textfield.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textfield.inc,v
retrieving revision 1.21.2.7
diff -u -r1.21.2.7 textfield.inc
--- components/textfield.inc	17 Oct 2010 21:52:38 -0000	1.21.2.7
+++ components/textfield.inc	18 Oct 2010 06:21:51 -0000
@@ -132,11 +132,10 @@
     '#field_suffix' => empty($component['extra']['field_suffix']) ? NULL : ($filter ? _webform_filter_xss($component['extra']['field_suffix']) : $component['extra']['field_prefix']),
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
     '#attributes' => $component['extra']['attributes'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
-    '#element_validate' => array(),
   );
 
   if ($component['extra']['disabled']) {
@@ -171,7 +170,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_textfield',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#field_prefix' => $component['extra']['field_prefix'],
     '#field_suffix' => $component['extra']['field_suffix'],
Index: components/time.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v
retrieving revision 1.24.2.13
diff -u -r1.24.2.13 time.inc
--- components/time.inc	17 Oct 2010 21:52:38 -0000	1.24.2.13
+++ components/time.inc	18 Oct 2010 06:21:51 -0000
@@ -131,12 +131,12 @@
     '#required' => $component['mandatory'],
     '#weight' => $component['weight'],
     '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
-    '#prefix' => '<div class="webform-component webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
-    '#suffix' => '</div>',
-    '#theme' => 'webform_time',
     '#element_validate' => array('webform_validate_time'),
     '#hourformat' => $component['extra']['hourformat'],
+    '#theme' => 'webform_time',
+    '#theme_wrappers' => array('webform_element_wrapper'),
     '#pre_render' => array('webform_element_title_display'),
+    '#post_render' => array('webform_element_wrapper'),
     '#webform_component' => $component,
   );
 
@@ -239,7 +239,7 @@
     '#title' => $component['name'],
     '#weight' => $component['weight'],
     '#theme' => 'webform_display_time',
-    '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
+    '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
     '#post_render' => array('webform_element_wrapper'),
     '#format' => $format,
     '#hourformat' => $component['extra']['hourformat'],
@@ -254,7 +254,7 @@
  */
 function theme_webform_display_time($element) {
   $output = ' ';
-  if (isset($element['#value']['hour']) && isset($element['#value']['minute'])) {
+  if (isset($element['#value']['hour']) && $element['#value']['hour'] !== '' && isset($element['#value']['minute']) && $element['#value']['minute'] !== '') {
     if ($element['#hourformat'] == '24-hour') {
       $output = sprintf('%02d', $element['#value']['hour']) . ':' . sprintf('%02d', $element['#value']['minute']);
     }
Index: css/webform-admin.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/css/webform-admin.css,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 webform-admin.css
--- css/webform-admin.css	17 Oct 2010 18:53:09 -0000	1.1.2.4
+++ css/webform-admin.css	18 Oct 2010 06:21:51 -0000
@@ -1,12 +1,5 @@
 /* $Id: webform-admin.css,v 1.1.2.4 2010/10/17 18:53:09 quicksketch Exp $ */
 
-.webform-display-item {
-  margin-top: 0.5em;
-  margin-bottom: 0.5em;
-}
-.webform-display-item label {
-  display: inline;
-}
 .webform-submission-navigation {
   text-align: right;
 }
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.196.2.66
diff -u -r1.196.2.66 webform.module
--- webform.module	17 Oct 2010 21:55:20 -0000	1.196.2.66
+++ webform.module	18 Oct 2010 06:21:50 -0000
@@ -509,6 +509,9 @@
     'webform_element' => array(
       'arguments' => array('element' => NULL, 'value' => NULL),
     ),
+    'webform_element_wrapper' => array(
+      'arguments' => array('element' => NULL, 'content' => NULL),
+    ),
     'webform_element_text' => array(
       'arguments' => array('element' => NULL, 'value' => NULL),
     ),
@@ -2366,7 +2369,6 @@
 function theme_webform_element($element, $value) {
   $wrapper_classes = array(
    'form-item',
-   $element['#format'] == 'html' ? 'webform-display-item' : 'webform-item',
   );
   $output = '<div class="' . implode(' ', $wrapper_classes) . '" id="' . $element['#id'] . '-wrapper">' . "\n";
   $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
@@ -2388,6 +2390,30 @@
 }
 
 /**
+ * Wrap form elements in a DIV with appropriate classes and an ID.
+ *
+ * This is a temporary work-around until we can use theme_webform_element() for
+ * all webform form elements in Drupal 7.
+ */
+function theme_webform_element_wrapper($element, $content) {
+  // All elements using this for display only are given the "display" type.
+  if (isset($element['#format']) && $element['#format'] == 'html') {
+    $type = 'display';
+  }
+  else {
+    $type = (isset($element['#type']) && !in_array($element['#type'], array('markup', 'textfield'))) ? $element['#type'] : $element['#webform_component']['type'];
+  }
+
+  $parents = str_replace('_', '-', implode('-', array_slice($element['#parents'], 1)));
+
+  $output = '';
+  $output .= '<div class="webform-component webform-component-' . $type . '" id="webform-component-' . $parents . '">';
+  $output .= $content;
+  $output .= '</div>';
+  return $output;
+}
+
+/**
  * Output a form element in plain text format.
  */
 function theme_webform_element_text($element, $value) {
