You are here

function template_preprocess_bef_hidden in Better Exposed Filters 8.3

Same name and namespace in other branches
  1. 8.5 includes/better_exposed_filters.theme.inc \template_preprocess_bef_hidden()
  2. 8.4 includes/better_exposed_filters.theme.inc \template_preprocess_bef_hidden()

Implements hook_template_preprocess_default_variables_alter().

File

./better_exposed_filters.module, line 112
Allows the use of checkboxes, radio buttons or hidden fields for exposed Views filters.

Code

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

  // bef_hidden is only used for multi-select elements being converted to
  // hidden.
  $variables['isMultiple'] = TRUE;
  $variables['selected'] = empty($element['#value']) ? $element['#default_value'] : $element['#value'];
  $variables['hiddenElements'] = [];
  foreach ($element['#options'] as $value => $label) {
    $variables['hiddenElements'][$value] = [
      '#type' => 'hidden',
      '#value' => $value,
      '#name' => $element['#name'] . '[]',
    ];
  }

  // @todo:
  // Check for optgroups.  Put subelements in the $element_set array and add a
  // group heading. Otherwise, just add the element to the set.

  //$element_set = array();

  //if (is_array($elem)) {

  //  $element_set = $elem;

  //}

  //else {

  //  $element_set[$option] = $elem;

  //}
}