Problem/Motivation
In #2625136: Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements exposed numeric/date filters with multiple form elements were updated to show 'Min' and 'Max' as their labels. Although this overall was an improvement, these labels don't make much sense with a date filter. It would be better if they were configurable.

Steps to reproduce
- Create a View of Articles
- Add a Filter for 'Authored on'
- Expose the filter
- Set the operator to 'Between'
- Change the minimum and maximum labels to 'From' and 'To'
Proposed resolution
We can already configure the placeholder text, let's add config to override the labels as well.
Remaining tasks
- Confirm we want this feature
- Write a patch with tests
- Review
User interface changes
New "Minimum label" and "Maximum label" fields are added to views filter forms of the numeric plugin and those that extend it.
. The numeric filter defaults are "Minimum" and "Maximum", the date (which extends numeric) defaults are "Start date" and "End date".
API changes
N/A
Data model changes
N/A
Release notes snippet
See change record https://www.drupal.org/node/3560313
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | configure-minimum-maximum-filter.png | 62.18 KB | scott_euser |
| #44 | exposed-defaults.png | 69.48 KB | scott_euser |
| #44 | id-2.png | 101.04 KB | scott_euser |
| #44 | id.png | 68.1 KB | scott_euser |
| #44 | date-2.png | 100.97 KB | scott_euser |
Issue fork drupal-3182064
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
Comment #7
michael.friend commentedAny updates on this request? We are trying to override the Min and Max labels now on a government site.
Comment #8
pameeela commented@michael.friend patches welcome anytime.
Comment #9
pameeela commentedYou can also do this with a form_alter, e.g. for a date range filter:
Comment #10
id.conky commented@michael.friend you can use merge request diff as patch
https://git.drupalcode.org/project/drupal/-/merge_requests/2391/diffs.patch
Comment #11
pameeela commentedOops I didn’t even notice the MR! So next steps are get the tests passing, and then get a review of the patch.
FYI it is not recommended to use MR diffs as patches as this is a security (and stability) risk because the diff link is not pinned to anything. You should create a patch file in your repo instead.
https://github.com/cweagans/composer-patches/issues/347
Comment #12
pameeela commentedComment #13
sophiavs commentedHi, i'll try to work on those errors :)
Comment #14
sophiavs commentedNow the tests are passing without errors :)
Comment #15
diegorsI'll review it.
Comment #16
diegorsApplied the #14 patch and works as well.
Steps:
- Added a filter to Post date to a view.
- Configured the operator to is between, and check the: Expose this filter to visitors.
- Set the min and max labels.
Everything is working, I suggest moving to RTBC.
Comment #17
diegorsComment #18
abhijith s commentedApplied patch #14 on 9.5.x. The Min and Max label configuration fields are appearing in view configuration after applying this patch.The label change is reflecting in the view page as well.
Attaching screenshot below.
After patch:
Comment #19
dmariano commentedI will review that!
Comment #20
dmariano commentedI applied the pacth #14 and everything worked fine.
Comment #21
dmariano commentedComment #22
alexpottWe should add some test coverage of the new capability. And we should have a change notice to announce it to the community.
Plus what about existing views when they are resaved? Do they change max_label and min_label added? I.e. do we need to think about upgrade path?
Comment #23
alexpottAlso meant to add to #22 that this change makes lots of sense and will be useful.
Comment #25
nikhil_110 commentedPatch #14 also applies to Drupal 10.1.x-dev
Comment #26
smustgrave commented#22 mentions the need for tests and a change record. Not ready for review yet.
Comment #28
ranjith_kumar_k_u commentedAdded tests, please review
Comment #30
smustgrave commentedMoving back to NW for change record.
Also with the schema change it will need an update hook.
Comment #31
lindsay.wils commentedIve just tested this on D11.2.4 and it all works.
Comment #32
igorgoncalves commentedThis is exactly what i was looking for.
Thanks.
Works great for Drupal 10.5.2
Comment #37
scott_euser commentedThanks everyone for the work on this. Updates made:
Comment #38
scott_euser commentedUpdated tag now that change record exists
Comment #39
scott_euser commentedUpdated issue summary with steps to reproduce (was missing)
Comment #40
dcam commentedThe code changes look ok to me. I tested the changes with number, date, and timestamp fields. In all cases the new label fields were added to the views filter form.
I also tested this issue's compatibility with #3204558: Timestamp field type uses numeric filter and argument plugins rather than date in Views, which will change the filter handler for timestamp fields. Since the date handler extends the numeric filter, there's no problem. It retains the new label elements after applying the additional changes.
The issue summary needed to be updated with the changes to the user interface. I reused the image from the change record. The change record itself looks good.
In response to the questions of #22:
The defaults of "Min" and "Max" are used. There was no issue with my test view after the patch was applied, but not after resaving the view. The defaults were displayed in the exposed form and the filter plugin forms. Everything continued to work after resaving. From what I can see we don't need an upgrade path because the defaults were set up correctly.
I am marking this as RTBC, but there is something that I don't like about this. The use of the abbreviations "Min" and "Max" doesn't sit right with me. I'm fairly certain that my accessibility reviewer would flag it as a problem. But it's used throughout the elements of the Numeric filter plugin. I didn't dig far into it, but it's been this way in the admin interface a long time since before Views was added to Core. I wonder if they ever underwent usability review. The terms are vague, as are the purposes of the fields they define. It's no wonder that people want to relabel them on the front end. The only reason I'm not suggesting the new element labels be changed now is because the terms are ubiquitous. But I am suggesting to the committer that a follow-up be opened for evaluating whether they should be changed throughout the form.
Comment #41
xjmThanks for your work on this issue! Providing review both in my capacity as a committer and as a Views subsystem maintainer (and Views in Drupal Core initiative team member from back in 2012-2013).
We still need automated test coverage in the canonical MR. Was it maybe applied to a hidden branch by mistake?
I agree with the previous review that "Min label" and "Max label" are (ironically) not great labels. We generally don't use abbreviations like that in the user interface; it's against our content style guidelines. That said, in the screenshot in #18, we already have "Min placeholder" and "Max placeholder", so I guess Views is already violating the content style guidelines. (Not for the first time.)
I can actually answer this:
Several rounds of usability review, in fact, before both D7 and D8. But it was after the fact when Views already existed for years as a thing a developer built for developers. So, we had to prioritize. Views had so many features that we had to focus on the most-used elements (and on removing as many elements as possible).
In this case, I would recommend we come up with better, clearer labels for the fields that follow our content style guidelines, and then have a followup to fix the existing fields above it to match.
Speaking of usability review. In the old screenshots from back in 2022, there is a description on the fields that is redundant with the labels without adding any real information. We did a lot of work during Views in Drupal Core to remove these redundant descriptions from the Views UI. I don't see these descriptions in the schema in the MR, though, so are they being inherited, or is it a mismatch between the screenshot and the MR?
If they are being inherited, it's worth either overriding it or a followup to fix the parent to not have redundant noise everywhere in the Views UI. Because if that snuck in somehow, it undid weeks of VDC and usability team collaboration and that makes me sad.
In either case, let's get updated screenshots to confirm the behavior, since it's been a few years.
Finally... There's the decision of whether to add these elements to Views in core, or whether the functionality should live in contrib. I'm on the fence about that still, but I think answers to the above questions and improved usability will help us decide. I'm leaning toward including it, because while this does add UI bloat for site builders, it also feels like the previous issue in #2625136: Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements got us sort-of-halfway-there for the actual site users' experience.
Comment #42
xjmHmm. After thinking about this for a few minutes, I am also wondering if the default values for these labels are also not-the-best. Certainly, we need to change the defaults to use whole words. That will cut the need to override this by at least 10%.
For dates, I think we should just ship default config of "Start date" and "End date".
Comment #44
scott_euser commentedI need to check why the tests are failing, but out of time this morning.
Updated screenshots of date & non-date to show label defaults if not changing any config, did this by going to the admin > content view and adding exposed filters.
For Date (authored on / created):
For Node ID (nid):
And the output in the exposed filter:
Comment #45
scott_euser commentedOn the descriptions: the old screenshots were a mismatch with the MR at the time. The descriptions ("Title for the Min field.", "Title for the Max field.") were added in the original patch code — they were not inherited from the parent FilterPluginBase. In the current MR they have been removed, in line with the usability work you're describing.
I have updated the issue summary and change record with an updated screenshot reflecting the current MR + described the labels as Minimum and Maximum and Start date and End date for date + have added test coverage for that.
Tests also passing now, there was a workspace test failure that was unrelated, and just hitting rerun was enough for that to pass.
I didn't change the placeholders from "Min placeholder" nor the field description there as its not really whats discussed in the issue summary, but it would be easy of course to extend the scope to that if you prefer.
Finally I removed the Needs tests and Needs screenshots tags since those are added, apologies if I shouldn't have done that myself (not sure the etiquette).
Comment #46
smustgrave commentedCan we get an update hook since these are new keys being added to views.
Are there any test views we will need to update?
Comment #47
scott_euser commentedThanks for the feedback!
I added an upgrade path based on the existence of min_placeholder rather than filter plugin ID to capture extensions to numeric/date. I set it up to maintain the status quo of 'Min' and 'Max' to be least disruptive to existing sites - hope that makes sense. So essentially new sites would take advantage of Minimum/Maximum/Start date/End date and existing sites could follow the change request to take advantage of that.
I also updated all existing test views that contained min_placeholder to add in the min_label & max_label
Comment #48
scott_euser commentedAh and I updated the change record again to indicate that e.g. contrib module maintainers that have test views in their config install should also do such an update
Comment #49
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #50
scott_euser commentedResolved merge conflict
Comment #51
scott_euser commentedLegitimate failure, looks like fixtures in the test coverage need an update again
Comment #52
scott_euser commentedOkay back to needs review, tests now pass again (fixtures updated)
Comment #53
smustgrave commentedUpgrade path looks good.
Needs follow up was added above with
But I see the label has been updated so does the follow up need to be a in general update? Happy to open just not 100% sure what the scope should be.
Manually tested by adding a 'created' filter to the default content view on a standard install.
Verified that the form appears as the screenshot and changing the labels works as expected on the frontend.
Definitely a feature that comes up often kudos!
Comment #54
alexpottI merged back to 11.x and resolved the conflicts.
Committed c6e7444 and pushed to main. Thanks!
Committed f00162f and pushed to 11.x. Thanks!
Comment #58
godotislateI think this broke 11.x: https://git.drupalcode.org/project/drupal/-/jobs/12137259
Maybe we can just add
#[IgnoreDeprecations]to the test?Comment #59
quietone commentedI agree, I just came here to report the same problem.
Comment #61
godotislateFix per #58: https://git.drupalcode.org/project/drupal/-/merge_requests/17093
Comment #62
godotislateBTW, if you, like me, were wondering why the MR status and comments aren't showing up in this issue thread: https://git.drupalcode.org/project/drupalorg/-/work_items/3607033
Comment #63
quietone commentedYes, ignoring the deprecation warnings for the 11.x branch makes sense on this update test.
Comment #65
longwaveCommitted 667ea93 and pushed to 11.x. Thanks!
Comment #67
quietone commentedUpdate and publish the change record.