How to get a separate form_id for each of the taxonomy/term/%term exposed form? I'm trying to combine in a smart way Contextual filters Has taxonomy term ID with Remember the last selection feature of exposed form filters in a view.

Context


A taxonomy vocabulary called destinations (countries &amp; regions)
A view of content tagged with destinations terms : Contextual filters : Content: Has taxonomy term ID (with depth)
Exposed filters such as travel duration, price...
Important point, Remember the last selection is ticked for all the filters
Ajax enabled, and the whole thing displayed as a content pane


The issue

Let's say I visit taxonomy/term/spain and filter the view by price &lt; 700$, then go to taxonomy/term/india e.g, the view will be already filtered by price &lt; 700$, and may return empty result, which is an unwanted behaviour.

This is because across all the taxonomy/term/% paths, the exposed form form_id remains the same views_exposed_form.

How could I get a separate form_id for each of the taxonomy/term/% exposed form, so that the last selection would be kept for each term ?

Or setup my view in order to get the expected features ?
Without patching the module you can't...but the View object is always available in the form state, so you can use that to check where you are. e.g.

function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    $view = $form_state['view'];
    if ($view-&gt;name == 'foo' &amp;&amp; $view-&gt;current_display == 'bar') {
      // ...
    }
  }
}