You are here

function theme_hierarchical_select in Hierarchical Select 7.3

Same name and namespace in other branches
  1. 5.3 hierarchical_select.module \theme_hierarchical_select()
  2. 6.3 includes/theme.inc \theme_hierarchical_select()

Format a hierarchical select.

Parameters

array $variables: An associative array containing the properties of the element.

Return value

string A themed HTML string representing the form element.

1 theme call to theme_hierarchical_select()
hierarchical_select_element_info in ./hierarchical_select.module
Implements hook_element_info().

File

includes/theme.inc, line 66
All theme functions for the Hierarchical Select module.

Code

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

  // Update $element['#attributes']['class'].
  if (!isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = array();
  }
  $hsid = $element['hsid']['#value'];
  $level_labels_style = variable_get('hierarchical_select_level_labels_style', 'none');
  $classes = array(
    'hierarchical-select-wrapper',
    "hierarchical-select-level-labels-style-{$level_labels_style}",
    // Classes that make it possible to override the styling of specific
    // instances of Hierarchical Select, based on either the ID of the form
    // element or the config that it uses.
    'hierarchical-select-wrapper-for-name-' . $element['#id'],
    isset($element['#config']['config_id']) ? 'hierarchical-select-wrapper-for-config-' . $element['#config']['config_id'] : NULL,
  );
  $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $classes);
  $element['#attributes']['id'] = "hierarchical-select-{$hsid}-wrapper";
  $element['#id'] = "hierarchical-select-{$hsid}-wrapper";

  // This ensures the label's for attribute is correct.
  return '<div ' . drupal_attributes($element['#attributes']) . '>' . drupal_render_children($element) . '</div>';
}