Option NONE in dropdown list instead of ALL

Created on 18 August 2017, over 7 years ago
Updated 30 April 2024, 8 months ago

By default, when you create an exposed dropdown list filter, you either have to select a default content record which would be selected once the form is loaded in public or use the filter with the option ANY or ALL, which is checked by default, showing all results needed.

We needed an option which does the opposite of ANY, when there is no selection, then don't show any records. There for we extended the module providing an additional option, the ability to prepand NONE, which is could be triggered through a checkbox for each of these filters. The idea of the option is to replace ANY or ALL from the dropdown list without having the need to select a default Content option and prevent displaying records until an actual filter option is being selected.

This is accomplished by setting a dummy value for the new option, which is inserted it at the top of the list through in the extended exposedFormAlter method, just before the rewriteOptions method, so the label NONE could be replaced with some other name if necessary using the Rewrite filter option - Rewrite text displayed.
Later a form alter method has been provided inside the .module which filter form IDs with the name `views_exposed_form` and go through the exposed filters which have #default_value option set and does not have a selected value sent - $_GET or $_POST variable with the filter name. If there is such found, set #value to #default_value.

In order to remove the ANY or ALL option from the dropdown list, you can use Rewrite filter option. For example: - Any -|, provide current string on the left and empty string on the right.

✨ Feature request
Status

Closed: outdated

Version

6.0

Component

Code

Created by

πŸ‡§πŸ‡¬Bulgaria svetoslav.dragoev

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States maskedjellybean Portland, OR

    Does anyone else think "none" is misleading when used this way? I'm on the hunt for a way to introduce a "none" option that works like this: Given an exposed filter based on a taxonomy reference field, selecting "none" would return all results where there is no value set for the field. This is different from what it sounds like this patch does (returns nothing), but I think it's an appropriate use of the word none. As @pcambra hints at in the screenshot in #13, "Select one" seems like more appropriate terminology for what's happening here.

  • @maskedjellybean

    I've seen a couple of pasts from you about this need for "note set", which I found while looking for a neater solution than I already have, which is not ideal but I thought I would share as it doesn't rely on hooks.

    This is zoomed out so you can see all the relevant settings, but if you make your filter a grouped filter, you can set options for 'Yes', 'No' and 'Not Set' for Booleans (and indeed other types).

    Just add new grouped filters for each possible option, and then a new options which is "is none of", and select all possible options. This gives you the 'not set' I think you are looking for.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Not sure I follow the use case here. Can issue summary be updated to use a standard issue template please.

  • Status changed to Postponed: needs info 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Closed: outdated 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Going to close as outdated, πŸ“Œ Rewriting the text displayed for "- All -" label should occur before translation Fixed may be related but would need more detail

    If still a unique issue please reopen.

Production build 0.71.5 2024