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
- Add a "List (integer)" field to an entity type
- Add a filter for that list field to a view that displays that entity type
- 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
Comments
Comment #1
dawehnerThere should be in general a filter_in_operator handler with numeric.
This could be used here.
Comment #2
merlinofchaos commentedWe do have to be careful here because once you get multi, things don't work well using the non-equality operators.
Comment #3
wedou commentedWhat do you mean by that, merlinofchaos?
Comment #4
neoglez commentedIt's this still valid ??
Comment #5
neoglez commentedIf i understand right this has been done already.
Comment #6
dawehnerNo this wasn't done yet.
Comment #7
esmerel commentedComment #8
rarioj commentedI 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.
Comment #9
finex commentedThe 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?
Comment #10
xandeadx commentedViews numeric filter for lists
Comment #11
andypost@xandeadx please, provide a patch
Suppose this issue should be moved to core and needs tests
Comment #12
alan d. commentedI seem to need this a lot and would be great to have this in core / views :)
Comment #13
andypostSuppose here is a proper place for now
Comment #25
quietone commentedI'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!
Comment #26
alex.bukach commentedJust tested it on a fresh Drupal 11.2.x install, and the issue still exists. Here are the steps to reproduce it:
Comment #27
quietone commented@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.
Comment #29
alex.bukach commentedComment #30
alex.bukach commentedHere are respective patches.
Comment #31
igorgoncalves commentedThanks @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.
Comment #32
smustgrave commentedEven though a task feel we should have some test coverage for the new functionality