1.20.x views.theme.inc template_preprocess_views_exposed_form(&$variables)

Default theme function for all filter forms.

File

modules/views/templates/views.theme.inc, line 1040
Preprocessors and helper functions to make theme development easier.

Code

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

  // Put all single checkboxes together in the last spot.
  $checkboxes = '';

  if (!empty($form['q'])) {
    $variables['q'] = backdrop_render($form['q']);
  }

  $variables['widgets'] = array();
  foreach ($form['#info'] as $id => $info) {
    // Set aside checkboxes.
    if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') {
      $checkboxes .= backdrop_render($form[$info['value']]);
      continue;
    }
    $widget = new stdClass;
    // set up defaults so that there's always something there.
    $widget->label = $widget->operator = $widget->widget = $widget->description = NULL;

    $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : '';

    if (!empty($info['label'])) {
      $widget->label = check_plain($info['label']);
    }
    if (!empty($info['operator'])) {
      $widget->operator = backdrop_render($form[$info['operator']]);
    }

    $widget->widget = backdrop_render($form[$info['value']]);

    if (!empty($info['description'])) {
      $widget->description = check_plain($info['description']);
    }

    $variables['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->id = 'checkboxes';
    $widget->widget = $checkboxes;
    $variables['widgets']['checkboxes'] = $widget;
  }

  if (isset($form['sort_by'])) {
    $variables['sort_by'] = backdrop_render($form['sort_by']);
    $variables['sort_order'] = backdrop_render($form['sort_order']);
  }
  if (isset($form['items_per_page'])) {
    $variables['items_per_page'] = backdrop_render($form['items_per_page']);
  }
  if (isset($form['offset'])) {
    $variables['offset'] = backdrop_render($form['offset']);
  }
  if (isset($form['reset'])) {
    $variables['reset_button'] = backdrop_render($form['reset']);
  }
  // This includes the submit button.
  $variables['button'] = backdrop_render_children($form);
}