function template_preprocess_views_exposed_form

Default theme function for all filter forms.

File

theme/theme.inc, line 972

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 = $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 = drupal_render($form[$info['operator']]);
        }
        $widget->widget = drupal_render($form[$info['value']]);
        if (!empty($info['description'])) {
            $widget->description = check_plain($info['description']);
        }
        $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;
    }
    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_children($form);
}