You are here

function theme_select_as_radios_fieldset in Better Exposed Filters 7

Same name and namespace in other branches
  1. 6.3 better_exposed_filters.theme \theme_select_as_radios_fieldset()
  2. 6 better_exposed_filters.theme \theme_select_as_radios_fieldset()
  3. 6.2 better_exposed_filters.theme \theme_select_as_radios_fieldset()
  4. 7.3 better_exposed_filters.theme \theme_select_as_radios_fieldset()

Themes a select element as a collection of radio buttons enclosed in a collapsible fieldset

Parameters

array $vars - An array of arrays, the 'element' item holds the properties of the element.: Properties used: title, value, options, description

Return value

HTML string representing the form element.

1 string reference to 'theme_select_as_radios_fieldset'
better_exposed_filters_theme in ./better_exposed_filters.module
Implements hook_theme().

File

./better_exposed_filters.theme, line 187

Code

function theme_select_as_radios_fieldset($vars) {

  // Merge incoming element with some default values. Prevents a lot of
  //    $foo = isset($bar) ? $bar : $bar_default;
  $element = array_merge(array(
    '#bef_title' => '',
    '#bef_description' => '',
  ), $vars['element']);

  // The "all" option is the first in the list. If the selected radio button is the all
  // option, then leave the fieldset collapsed.  Otherwise, render it opened.
  $all = array_shift(array_keys($element['#options']));
  $fieldset = array(
    '#title' => $element['#bef_title'],
    '#description' => $element['#bef_description'],
    '#attributes' => array(
      'class' => array(
        'bef-select-as-checkboxes-fieldset',
        'collapsible',
      ),
    ),
  );
  if (empty($element['#value'])) {

    // Using the FAPI #collapsible and #collapsed attribute doesn't work here
    // TODO: not sure why...
    $fieldset['#attributes']['class'][] = 'collapsed';
  }
  $fieldset['#children'] = theme('select_as_radios', $element);
  return theme('fieldset', array(
    'element' => $fieldset,
  ));
}