You are here

function theme_multiselect in Multiselect 7

Returns HTML for a select form element.

It is possible to group options together; to do this, change the format of $options to an associative array in which the keys are group labels, and the values are associative arrays in the normal $options format.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #extra, #multiple, #required, #name, #attributes, #size.
1 theme call to theme_multiselect()
multiselect_element_info in ./multiselect.module
Implements hook_element_info().

File

./multiselect.module, line 373
Allows users to select multiple items in an easier way than the normal node-reference widget.

Code

function theme_multiselect($variables) {
  $element = $variables['element'];
  element_set_attributes($element, array(
    'id',
    'name',
    'size',
    'multiple',
    'default_value',
    'required',
  ));
  _form_set_class($element, array(
    'form-multiselect',
  ));
  $options = $element['#options'];

  // All available options as defined by the element
  $items = $element['#default_value'];

  // All selected options are referred to as "items".
  $element['#field_name'] = $element['#name'];

  // CCK calls the #name "#field_name", so let's duplicate that..
  $required = $element['#required'];
  $widget = _multiselect_build_widget_code($options, $items, $element, $required);

  // Add a couple of things into the attributes.
  $element['#attributes']['class'][] = $widget['selfield'];
  $element['#attributes']['class'][] = "multiselect_sel";
  $element['#attributes']['id'] = $element['#field_name'];
  return $widget['prefix_pre'] . $widget['prefix_options'] . $widget['prefix_post'] . '<div class="form-item form-type-select"><select' . drupal_attributes($element['#attributes']) . '>' . _multiselect_html_for_box_options($widget['selected_options']) . '</select></div>' . "\n</div>\n";
}