function template_preprocess_views_exposed_form
Same name in other branches
- 7.x-3.x theme/theme.inc \template_preprocess_views_exposed_form()
Default theme function for all filter forms.
File
-
theme/
theme.inc, line 799
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 = isset($form[$info['value']]['#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->id = 'checkboxes';
$widget->widget = $checkboxes;
$vars['widgets']['checkboxes'] = $widget;
}
// Don't render these:
unset($form['form_id']);
unset($form['form_build_id']);
unset($form['form_token']);
if (isset($form['sort_by'])) {
$vars['sort_by'] = drupal_render($form['sort_by']);
$vars['sort_order'] = drupal_render($form['sort_order']);
}
if (isset($form['items_per_page'])) {
$vars['items_per_page'] = drupal_render($form['items_per_page']);
}
if (isset($form['offset'])) {
$vars['offset'] = drupal_render($form['offset']);
}
if (isset($form['reset'])) {
$vars['reset_button'] = drupal_render($form['reset']);
}
// This includes the submit button.
$vars['button'] = drupal_render($form);
}