summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2009-06-01 21:49:19 (GMT)
committer Earl Miles2009-06-01 21:49:19 (GMT)
commit53d93a1e3733151acde0a216657519b92fb76b11 (patch)
tree5ae0721192c267e837ba0965747a0e8f26ed6425
parentcaa29a1a6a43a079ad5a22326d2041d9bd949966 (diff)
#358314 by brmassa: Catch the exposed filter form so it doesn't process twice on a single view.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--views.module34
2 files changed, 35 insertions, 0 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index d06d357..a669b0a 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -7,6 +7,7 @@ Views 2.x
o #323049 by yched: Allow Empty/Not Empty on select many to one.
o #340701 by swentel: Restore allowing Views to set block caching mode.
o #347892 by dww: Allow <any> option in Boolean filters.
+ o #358314 by brmassa: Catch the exposed filter form so it doesn't process twice on a single view.
Views 2.5
Bugs fixed:
diff --git a/views.module b/views.module
index 72e4f5d..e3d0b7c 100644
--- a/views.module
+++ b/views.module
@@ -934,6 +934,11 @@ function views_exposed_form(&$form_state) {
$view = &$form_state['view'];
$display = &$form_state['display'];
+ // Check if the form was already created
+ if ($cache = views_exposed_form_cache($view->name, $view->current_display)) {
+ return $cache;
+ }
+
$form_state['input'] = $view->get_exposed_input();
// Let form plugins know this is for exposed widgets.
@@ -974,6 +979,10 @@ function views_exposed_form(&$form_state) {
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;
}
@@ -1009,6 +1018,31 @@ function views_exposed_form_submit(&$form, &$form_state) {
}
}
+/**
+ * Save the Views exposed form for later use.
+ *
+ * @param $views_name
+ * String. The views name.
+ * @param $display_name
+ * String. The current view display name.
+ * @param $form_output
+ * Array (optional). The form structure. Only needed when inserting the value.
+ * @return
+ * Array. The form structure, if any. Otherwise, return FALSE.
+ */
+function views_exposed_form_cache($views_name, $display_name, $form_output = NULL) {
+ static $views_exposed;
+
+ // Save the form output
+ if (!empty($form_output)) {
+ $views_exposed[$views_name][$display_name] = $form_output;
+ return;
+ }
+
+ // Return the form output, if any
+ return empty($views_exposed[$views_name][$display_name]) ? FALSE : $views_exposed[$views_name][$display_name];
+}
+
// ------------------------------------------------------------------
// Misc helpers