From d462cafd50d5f7cbaab61f2cd271e3a5bc1df718 Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 11 Oct 2012 15:04:13 -0700 Subject: Issue #1742438 by larowlan, Christian Biggins, kim.pepper, dcam, Everett Zufelt, mgifford: Fixed Vertical tabs header and container rendered even when no vertical tabs. --- includes/form.inc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/form.inc b/includes/form.inc index 826b6777b..6a1e2f751 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -3735,11 +3735,25 @@ function form_process_vertical_tabs($element, &$form_state) { */ function theme_vertical_tabs($variables) { $element = $variables['element']; - // Add required JavaScript and Stylesheet. - drupal_add_library('system', 'drupal.vertical-tabs'); + // Even if there are no tabs the element will still have a child element for + // the active tab. We need to iterate over the tabs to ascertain if any + // are visible before showing the wrapper and h2. + $visible_tab = FALSE; + $output = ''; + foreach (element_children($element['group']) as $tab_index) { + if (!isset($element['group'][$tab_index]['#access']) || + !empty($element['group'][$tab_index]['#access'])) { + $visible_tab = TRUE; + break; + } + } + if ($visible_tab) { + // Add required JavaScript and Stylesheet. + drupal_add_library('system', 'drupal.vertical-tabs'); - $output = '

' . t('Vertical Tabs') . '

'; - $output .= '
' . $element['#children'] . '
'; + $output = '

' . t('Vertical Tabs') . '

'; + $output .= '
' . $element['#children'] . '
'; + } return $output; } -- cgit v1.2.3