You are here

function template_preprocess_views_exposed_form in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 8.3 theme/theme.inc \template_preprocess_views_exposed_form()
  2. 6.3 theme/theme.inc \template_preprocess_views_exposed_form()
  3. 7.3 theme/theme.inc \template_preprocess_views_exposed_form()

Default theme function for all filter forms.

File

theme/theme.inc, line 619
theme.inc

Code

function template_preprocess_views_exposed_form(&$vars) {
  $form =& $vars['form'];

  // Put all single checkboxes together in the last spot.
  $checkboxes = '';
  if (!empty($form['q'])) {
    $vars['q'] = drupal_render($form['q']);
  }
  $vars['widgets'] = array();
  foreach ($form['#info'] as $id => $info) {

    // Set aside checkboxes.
    if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') {
      $checkboxes .= drupal_render($form[$info['value']]);
      continue;
    }
    $widget = new stdClass();

    // set up defaults so that there's always something there.
    $widget->label = $widget->operator = $widget->widget = NULL;
    $widget->id = $form[$info['value']]['#id'];
    if (!empty($info['label'])) {
      $widget->label = $info['label'];
    }
    if (!empty($info['operator'])) {
      $widget->operator = drupal_render($form[$info['operator']]);
    }
    $widget->widget = drupal_render($form[$info['value']]);
    $vars['widgets'][$id] = $widget;
  }

  // Wrap up all the checkboxes we set aside into a widget.
  if ($checkboxes) {
    $widget = new stdClass();

    // set up defaults so that there's always something there.
    $widget->label = $widget->operator = $widget->widget = NULL;
    $widget->widget = $checkboxes;
    $vars['widgets']['checkboxes'] = $widget;
  }

  // Don't render these:
  unset($form['form_id']);
  unset($form['form_build_id']);
  unset($form['form_token']);

  // This includes the submit button.
  $vars['button'] = drupal_render($form);
}