Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292761

Configurable views filters to allow for different widgets

$
0
0

Problem/Motivation

Views filters are currently hard-coded to a single form element as part of the filter plugin definition. The only way to change the form element is to alter the views data, and this changes it globally.

This makes it hard for site builders to provide a nice user experience when setting up exposed filters.

Two core issues that show the problem are #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter (200 followers) and #3347343: Continuation Add Views EntityReference filter to be available for all entity reference fields (300 followers), both issues have been open for years.

https://www.drupal.org/project/better_exposed_filters exists in contrib to solve this problem, but comes with its own usability issues - the exposed filters settings are located in the views advanced panel, which is the opposite side of the views UI from filters and their exposed settings.

This means you have to add the filter, expose it, then go over to advanced settings, changed the exposed filters type, then configure the widgets. This isn't BEF's fault it's just a result of being implemented in contrib instead of directly.

Better Exposed Filters has over 100,000 modern Drupal installs putting it in the top 15 Drupal modules.

Steps to reproduce

Proposed resolution

Lots of details TBD but something like:

1. Create a new views plugin type for filterwidget
2. Implement text, select, checkboxes, radios, entity autocomplete plugins (at least) to start with.
3. When configuring a filter, add a widget selector when the filter is exposed which will choose from the options in #2.
4. Update filter settings in config to include the plugin selection.
5. Figure out more details like how to set a default widget, how to restrict widgets to certain filter types etc.
6. Reconcile this new generic method, with the custom implementations of widget selections such as in #3347343: Continuation Add Views EntityReference filter to be available for all entity reference fields.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 292761

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>