1.20.x options.theme.inc theme_options($variables)

Theme an options element.

File

modules/field/modules/options/options.theme.inc, line 39
Theme functions for the Options module.

Code

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

  element_set_attributes($element, array('id'));
  _form_set_class($element, array('form-options'));

  $classes = &$element['#attributes']['class'];
  $classes[] = 'options-key-type-' . $element['#key_type'];

  if ($element['#key_type_toggled']) {
    $classes[] = 'options-key-custom';
  }

  if (isset($element['#optgroups']) && $element['#optgroups']) {
    $classes[] = 'options-optgroups';
  }

  if (isset($element['#multiple']) && $element['#multiple']) {
    $classes[] = 'options-multiple';
  }

  // Replace the error class from wrapper div, which doesn't display well with
  // complex elements like Options.
  if ($key = array_search('error', $classes, TRUE)) {
    $classes[$key] = 'options-error';
  }

  $options = '';
  $options .= backdrop_render($element['options_field']);
  if (isset($element['default_value_field'])) {
    $options .= backdrop_render($element['default_value_field']);
  }
  if (isset($element['default_value_pattern'])) {
    $options .= backdrop_render($element['default_value_pattern']);
  }

  $settings = '';
  if (isset($element['custom_keys'])) {
    $settings .= backdrop_render($element['custom_keys']);
  }
  if (isset($element['multiple'])) {
    $settings .= backdrop_render($element['multiple']);
  }
  if (isset($element['option_settings'])) {
    $settings .= backdrop_render($element['option_settings']);
  }

  $output = '';
  $output .= '<div' . backdrop_attributes($element['#attributes']) . '>';
  $output .= theme('container', array('element' => array(
    '#title' => t('Options'),
    '#collapsible' => FALSE,
    '#children' => $options,
    '#attributes' => array('class' => array('options')),
  )));

  if (!empty($settings)) {
    $output .= theme('fieldset', array('element' => array(
      '#title' => t('Option settings'),
      '#collapsible' => FALSE,
      '#children' => $settings,
      '#attributes' => array('class' => array('option-settings')),
    )));
  }
  $output .= '</div>';

  return $output;
}