Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Form Filter Fields

No security coverage Maintenance fixes only 44 sites

This module allows you to create dependent dropdowns or select fields on your forms, where the options in one field change based on the selection in another. It uses Views to define the filtering logic, enabling complex relationships between taxonomy terms or other fields, and works with various form widgets.

If you need a taxonomy field to be filtered based off of another taxonomy field's value, this module is for you. It is handled via Views.

I originally used Business Rules to accomplish the filtering but Business Rules only allowed filtering of one child when we needed multiple. That is all this module does where Business Rules has a lot of other things; not just dependent fields.

This module handles multiple dependencies so if you have a field that needs to filter multiple fields in your form, this module can handle that.

It is configured through an admin form where you specify the following:

  • Node or Media Type - Which content or media type the two fields are on.
  • Control Field - The field which controls the results of the Target Field.
  • Target Field - The field which changes values based off of the Control Field.
  • View - The view which handles the filtering. This view has a contextual filter (which should be your Control Field). The view handles the filtering so however you need to filter the Target Field, you do it with the view. The output of the view needs to be an HTML list of fields where you rewrite the result as tid|Option Name.

Features

  • Easy to maintain relationships
  • Relates taxonomy terms to other taxonomy terms in different vocabularies
  • Views controls the dependencies so it's easy to order
  • Works with select2, checkboxes, drop downs, radio buttons, etc.
  • Created two hooks to allow developers added functionality:
    • one to alter the form before it's processed
    • one to do other stuff on the event that something else needs to change when a field changes (ex. populate or manipulate a text field, clear a field's value, etc)
  • Works with node and media bundle entities

Installation & Setup

  • Install and enable the module
  • Establish relationships in taxonomy terms by creating a field on the dependent
    vocabulary. Add dependencies on terms.
  • Create a view which gets a term ID from the control vocabulary (contextual
    filter). Rewrite the results so it's in this kind of format:
    tid|Name
    ex. 45|Ball

  • Go to /admin/config/content/form_filter_fields to add the relationship to your two fields.
  • Test and profit!

Related Modules

Known Issues

  • This module does not work with IEF (Inline Entity Form). Their way of creating forms is using a different object/class which is more complicated than Drupal's.
Drupal 8–10 · not 11

Ask your assistant about Form Filter Fields

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Feb 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
8.x-1.6 Stable 8–10 May 5, 2023
8.x-1.5 Stable 8–10 Feb 5, 2023