When using exposed filters that have default values set as "secondary options", submitting the exposed filters form results in the secondary fieldset being expanded. Similarly, if the secondary fieldset is expanded but no values are changed, the fieldset will remain open.

Instead of merely detecting for the existence of input, the input should be compared with the default values of each of the secondary filters.

I have a patch which seems to do this successfully with both single and multiple value exposed filters.

If you'll accept this feature, my question is, do you prefer to add an option to the BEF settings configuration or is this the desired behavior globally?

Attached is a feature which includes a view that provides a page at: /bef-secondary-collapse-test

The view includes both single value and multiple value exposed filters with and without default values.

The idea is that you should be able to submit the form without the secondary fieldset opening (or closing the fieldset if it was open but inputs were not changed from default).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lee20 created an issue. See original summary.

lee20’s picture

Attached is the patch.

One thing I'm not sure about is: It checks the input of exposed filters before checking whether or not it's a secondary. Shouldn't be a big deal, but it might be more ideal to check if it's secondary first, but the added method "filter_has_exposed_input" can be used generically this way.

lee20’s picture

Forgot to search the issue queue before submitting this. It looks like #2341807: Configure collapsed-state of secondary filters fieldset is related but that it hasn't addressed the comparison of default values.

junaidpv’s picture

We were looking for this and found this thread. The patch is working good for us. Thanks!

veroniqueg’s picture

I have a few issues with patch #2, I have some select widgets with values selected with 'Limit list to selected items'

It gives me a lot of

Warning: array_shift() expects parameter 1 to be array, string given in array_shift() (line 2160 of better_exposed_filters_exposed_form_plugin.inc).

And it detects default_value as the first value selected, and not 'All' as it should, so the secondary options is always opened

Also as you mentioned above, it will be more efficient if you test

$filter->options['exposed'] && $settings[$label]['more_options']['is_secondary'] && $this->filter_has_exposed_input($filter)

so it computes the exposed input only if it's exposed and secondary

Here is the patch that works for me in that case

veroniqueg’s picture

Status: Needs review » Needs work
lee20’s picture

Here is a re-roll of the patch from #2 which addresses the array_shift() issues mentioned in #5.

I couldn't get the patch from #5 to apply with or without the patch from #2.

Still needs work to support multiple selections afaik.

junaidpv’s picture

Re-rolled patch from comment#7 to for current release 7.x-3.6.

Neslee Canil Pinto’s picture

Status: Needs work » Closed (won't fix)

Hi, there will be no more future development for 7.x branch. If you see this issue in 8.x, feel free to file an issue. Closing this as Closed(wont fix).