Problem/Motivation

Views filters operators for numeric list fields are only "Is one of", "Is all of", "Is none of", "Is empty (NULL)", "Is not empty (NOT NULL)", but numeric filters like "Is equal to", "Is greater than", "Is greater than or equal to" are missing.

Steps to reproduce

  1. Add a "List (integer)" field to an entity type
  2. Add a filter for that list field to a view that displays that entity type
  3. See that available filter operators are only "Is one of", "Is all of", "Is none of", "Is empty (NULL)", "Is not empty (NOT NULL)", but numeric filters like "Is equal to", "Is greater than", "Is greater than or equal to" are missing.

Proposed resolution

Drupal 7 provided only numeric filter for number lists, however as D11 already provides ManyToOne filter for them, let's have 2 filters for such fields for back-compatibility: current one and a numeric one.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-1173808

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dawehner’s picture

There should be in general a filter_in_operator handler with numeric.
This could be used here.

merlinofchaos’s picture

Category: feature » task

We do have to be careful here because once you get multi, things don't work well using the non-equality operators.

wedou’s picture

What do you mean by that, merlinofchaos?

neoglez’s picture

Status: Active » Postponed (maintainer needs more info)

(...)for Integer field when using List (integer) field

It's this still valid ??

neoglez’s picture

If i understand right this has been done already.

dawehner’s picture

No this wasn't done yet.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Active
rarioj’s picture

I have the same issue. I expose a List (integer) field, but the expose filter setting does not allow me to select the operator that I want.

So I found a workaround by using the hook_views_query_alter. It overrides the operator value to something I desire.

function property_engine_views_query_alter(&$view, &$query)
{
  if ($view->name == 'property_search') { // make sure this is the correct view
    if (count($query->where[0]['conditions'])) {
      foreach ($query->where[0]['conditions'] as &$cond) {
        if ($cond['field'] == 'field_data_field_accomodates.field_accomodates_value') {
          $cond['operator'] = '>='; // override the operator (greater than and equal to)
        }
      }
    }
  }
}
finex’s picture

The workaround suggested by @rarioj works in the case you need a specific operator, but what should be done if you need to expose the common numerical operators as filters?

xandeadx’s picture

andypost’s picture

@xandeadx please, provide a patch

Suppose this issue should be moved to core and needs tests

alan d.’s picture

I seem to need this a lot and would be great to have this in core / views :)

andypost’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.x-dev
Component: exposed filters » views.module

Suppose here is a proper place for now

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I've been testing views issues for bugsmash and was searching for duplicates and found this issue. I tested a multivalue list integer field with exposed filters and exposed operator on Drupal 9.4.x, standard install, and they worked just fine.

Closing as outdated.

If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!

alex.bukach’s picture

Version: 9.4.x-dev » 11.2.x-dev
Assigned: Unassigned » alex.bukach
Status: Closed (outdated) » Active

Just tested it on a fresh Drupal 11.2.x install, and the issue still exists. Here are the steps to reproduce it:

  1. Add a "List (integer)" field to an entity type
  2. Add a filter for that list field to a view that displays that entity type
  3. See that available filter operators are only "Is one of", "Is all of", "Is none of", "Is empty (NULL)", "Is not empty (NOT NULL)", but numeric filters like "Is equal to", "Is greater than", "Is greater than or equal to" are missing. Those operators were available in Drupal 7.
quietone’s picture

Version: 11.2.x-dev » 11.x-dev
Issue tags: +Needs issue summary update

@alex.bukach, thanks for testing!

This needs an issue summary update, using the standard issue template. And the information from the previous commented added there.

If this problem was discovered on a version of Drupal that is not 11.x, add that information in the issue summary and leave the version at 11.x. In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies. Also mentioned on the version section of the list of issue fields documentation.

alex.bukach’s picture

Issue summary: View changes
alex.bukach’s picture

Assigned: alex.bukach » Unassigned
Status: Active » Needs review
StatusFileSize
new1.43 KB
new1.8 KB

Here are respective patches.

igorgoncalves’s picture

StatusFileSize
new43.38 KB

Thanks @alex.bukach

Just followed the steps to reproduce and i confirm that on a clean Drupal 11 instalation there's no "numeric filter" available for my integer field.

And testing with the Merge Request there's numeric filter (screenshot below) and when i applied, the filter works as it should with "greater than" option, for example.

image test

smustgrave’s picture

Status: Needs review » Needs work

Even though a task feel we should have some test coverage for the new functionality

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.