diff --git a/components/fieldset.inc b/components/fieldset.inc index cab1bff..e42aa78 100644 --- a/components/fieldset.inc +++ b/components/fieldset.inc @@ -55,19 +55,15 @@ function _webform_render_fieldset($component, $value = NULL, $filter = TRUE) { $element = array( '#type' => 'fieldset', '#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'], + '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : NULL, '#weight' => $component['weight'], '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], '#collapsible' => $component['extra']['collapsible'], '#collapsed' => $component['extra']['collapsed'], '#attributes' => array('class' => array('webform-component-fieldset'), 'id' => 'webform-component-' . $component['form_key']), - '#pre_render' => array('webform_fieldset_prerender'), + '#pre_render' => array('webform_fieldset_prerender', 'webform_element_title_display'), ); - // Hide the fieldset title if #title_display is 'none'. - if (!empty($component['extra']['title_display']) && $component['extra']['title_display'] == 'none') { - $element['#title'] = NULL; - } - return $element; } diff --git a/includes/webform.components.inc b/includes/webform.components.inc index 7b70c71..5c160f5 100644 --- a/includes/webform.components.inc +++ b/includes/webform.components.inc @@ -422,7 +422,7 @@ function webform_component_edit_form($form, $form_state, $node, $component, $clo $form['display']['title_display'] = array( '#type' => 'checkbox', '#title' => t('Hide label'), - '#default_value' => !empty($component['extra']['title_display']), + '#default_value' => strcmp($component['extra']['title_display'], 'none') === 0, '#return_value' => 'none', '#description' => t('Do not display the label of this component.'), ); diff --git a/webform.module b/webform.module index 0491be0..8a4a125 100644 --- a/webform.module +++ b/webform.module @@ -820,6 +820,8 @@ function webform_webform_component_info() { 'features' => array( 'csv' => FALSE, 'default_value' => FALSE, + 'description' => FALSE, + 'private' => FALSE, 'required' => FALSE, 'title_display' => FALSE, ), @@ -2613,6 +2615,19 @@ function template_preprocess_webform_mail_message(&$vars) { } /** + * A Form API #pre_render function. Sets display based on #title_display. + * + * This function is used regularly in D6 for all elements, but specifically for + * fieldsets in D7, which don't support #title_display natively. + */ +function webform_element_title_display($element) { + if (isset($element['#title_display']) && strcmp($element['#title_display'], 'none') === 0) { + $element['#title'] = NULL; + } + return $element; +} + +/** * Replacement for theme_form_element(). */ function theme_webform_element($variables) { @@ -2637,7 +2652,7 @@ function theme_webform_element($variables) { 'webform-component', 'webform-component-' . $type, ); - if (isset($element['#title_display']) && $element['#title_display'] == 'inline') { + if (isset($element['#title_display']) && strcmp($element['#title_display'], 'inline') === 0) { $wrapper_classes[] = 'webform-container-inline'; } $output = '
' . "\n";