This project is not covered by Drupal’s security advisory policy.

This module allows Views exposed filters that are on Entity Reference fields to have their visible options limited according to the values of other filters on the targeted entity type.

It is related to the Reference field option limit module, though does not require it.

Example

Suppose you have article nodes which have a reference field to the city node they are about. Each city node has a field for its country. You can use this module to create a view of article nodes with exposed filters for the country and city, where the city options are only those cities in the currently filtered countries.

The user of this view has this workflow:

  1. Load the view's page.
  2. Select one or more countries from the country filter and submit.
  3. The view updates to show articles for the selected countries. The city filter now shows only relevant cities.
  4. Select one or more cities and submit.

The steps to build this view are:

  1. configure the entityreference field on article that points to cities to provide the Views filter handler with limited options
  2. build the basic view showing article nodes
  3. add a relationship to city nodes
  4. add an exposed filter on the city relationship for the country field
  5. add an exposed filter for the city field. Configure it to be limited by the country field.

You can see the above in practice if you enable the hidden module that the tests use.

TODO

This module does not yet support:

  • contextual filters with multiple values and an AND operator, i.e. where the argument is of the form '1,2,3' rather than '1+2+3'.
  • default values on an exposed filter.
  • updating of the restricted filter options via AJAX.
  • having the restricted filter itself be on a chain of relationship, if these cause the relationship ID to be different from the underlying field name.
  • having limiting filters be on relationships themselves on the relationship that corresponds to the restricted field (so for example, a filter on a field on the author of the city nodes).
  • support for filters on other types of reference field, such as taxonomy term reference and Commerce product reference

If you require any of these features, please consider either providing a patch or sponsoring development.

Project information

Releases