function views_exposed_form in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 8.3 views.module \views_exposed_form()
- 6.3 views.module \views_exposed_form()
- 7.3 views.module \views_exposed_form()
Form builder for the exposed widgets form.
Be sure that $view and $display are references.
1 string reference to 'views_exposed_form'
- view::render_exposed_form in includes/
view.inc - Render the exposed filter form.
File
- ./
views.module, line 995 - Primarily Drupal hooks and global API functions to manipulate views.
Code
function views_exposed_form(&$form_state) {
// Don't show the form when batch operations are in progress.
if ($batch = batch_get() && isset($batch['current_set'])) {
return array(
// Set the theme callback to be nothing to avoid errors in template_preprocess_views_exposed_form().
'#theme' => '',
);
}
// Make sure that we validate because this form might be submitted
// multiple times per page.
$form_state['must_validate'] = TRUE;
$view =& $form_state['view'];
$display =& $form_state['display'];
$form_state['input'] = $view
->get_exposed_input();
// Let form plugins know this is for exposed widgets.
$form_state['exposed'] = TRUE;
// Check if the form was already created
if ($cache = views_exposed_form_cache($view->name, $view->current_display)) {
return $cache;
}
$form['#info'] = array();
if (!variable_get('clean_url', FALSE)) {
$form['q'] = array(
'#type' => 'hidden',
'#value' => $view
->get_url(),
);
}
// Go through each filter and let it generate its info.
foreach ($view->filter as $id => $filter) {
$view->filter[$id]
->exposed_form($form, $form_state);
if ($info = $view->filter[$id]
->exposed_info()) {
$form['#info']['filter-' . $id] = $info;
}
}
// @todo deal with exposed sorts
$form['submit'] = array(
'#name' => '',
// prevent from showing up in $_GET.
'#type' => 'submit',
'#value' => t('Apply'),
'#id' => form_clean_id('edit-submit-' . $view->name),
);
$form['#action'] = url($view
->get_url());
$form['#theme'] = views_theme_functions('views_exposed_form', $view, $display);
$form['#id'] = views_css_safe('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display->id));
// $form['#attributes']['class'] = array('views-exposed-form');
// If using AJAX, we need the form plugin.
if ($view->use_ajax) {
drupal_add_js('misc/jquery.form.js');
}
views_add_js('dependent');
// Save the form
views_exposed_form_cache($view->name, $view->current_display, $form);
return $form;
}