function theme_vertical_tabs

Returns HTML for an element's children details as vertical tabs.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties and children of the details element. Properties used: #children.

Related topics

File

drupal/core/includes/form.inc, line 3866
Functions for form and batch generation and processing.

Code

function theme_vertical_tabs($variables) {
  $element = $variables['element'];

  // 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 = '<h2 class="element-invisible">' . t('Vertical Tabs') . '</h2>';
    $output .= '<div class="vertical-tabs-panes">' . $element['#children'] . '</div>';
  }
  return $output;
}