facets_form
355 sites
Security covered
Exposes facets from a facets source as Drupal Form API elements.
Why?
Even displayed as a dropdown select or checkboxes, the facet widgets are rendered as link lists. Then a JavaScript snippet is responsible to convert them into form elements, such as <select> or <input type="checkbox">.
This has some drawbacks:
- Even the widgets are displayed as form elements, they are not piped through Drupal Form API. As a consequence, third-party code cannot perform form alterations, and they are not subject to standard Form API elements theming.
- The current Facets implementation is applying the filter as soon as the element is selected or checked. This is a UX issue, mostly on mobile devices. Also, it doesn't allow scenarios where the user wants to do multiple filter selection before the filters are submitted.
Usage
- Facets Form provides a block containing a form for each facets source.
- By default, each block is exposing all eligible facets. But the site builder is able to limit the list of facets to be exposed from the block configuration.
- The "submit" and "reset" buttons labels can be also be configured on block level.
- Eligible facets are all facets using widgets plugins that are extending the
\Drupal\facets_form\FacetsFormWidgetInterface. Facets Form module ships with two widgets, aiming to provide a Form API alternative to Facets module native widgets:- Dropdown (inside form)
facets_form_dropdown - Checkboxes (inside form)
facets_form_checkbox
- Dropdown (inside form)
- The
facets_form_date_rangesub-module provides a third, bonus, date range widget.
Extending
Third-party modules can provide additional widgets to be usable inside forms, by implementing the \Drupal\facets_form\FacetsFormWidgetInterface interface.