Exposed sort filters don't have the correct default values when they are used as a setting of a view pane.
I have the following scenario:
I have a view pane. I exposed a number of filter and sorting criteria as e settings of the pane. Whit the filter criteria I have no issues but the sorting settings are not prefilled with the previously selected option into the pane form.

I checked the views_plugin_exposed_form class which creates the form elements for the sort filtering and noticed that it does not populate the default values at all based on the input values. It always takes the default value and that's it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boyan.borisov’s picture

Status: Active » Needs review
FileSize
2.11 KB

I modified the views_plugin_exposed_form class to populated the default values based on $this->view->exposed_input

boyan.borisov’s picture

Please, ignore the patch from comment #1. It overrides some other changes on dev which I missed.

I am providing the correct patch.

boyan.borisov’s picture

Any comments?

Chris Matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch in #2 to views_plugin_exposed_form.inc does not apply to the latest views 7.x-3.x-dev and if still applicable needs reroll.

Checking patch plugins/views_plugin_exposed_form.inc...
error: while searching for:
    }

    if (count($exposed_sorts)) {
      $form['sort_by'] = array(
        '#type' => 'select',
        '#options' => $exposed_sorts,
        '#title' => $this->options['exposed_sorts_label'],
      );
      $sort_order = array(
        'ASC' => $this->options['sort_asc_label'],
        'DESC' => $this->options['sort_desc_label'],
      );
      if (isset($form_state['input']['sort_by']) && isset($this->view->sort[$form_state['input']['sort_by']])) {
        $default_sort_order = $this->view->sort[$form_state['input']['sort_by']]->options['order'];
      } else {
        $first_sort = reset($this->view->sort);

error: patch failed: plugins/views_plugin_exposed_form.inc:220
error: plugins/views_plugin_exposed_form.inc: patch does not apply
Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.36 KB

Patch rerolled.