I'm running Drupal 8 with two taxonomy vocabularies, which are as follows:

  • Color

    • Red
    • Blue
    • Green
  • Containers

    • A
    • B
    • C
    • D
    • E
    • F

My content has 2 term reference fields

  • Color
  • Containers

The first term reference can have multiple tags. What I'm trying to do is use the first vocabulary (Color) as exposed-filter/menu and the second (Containers) as term reference list on my views. I want to be able to show the second vocabulary (Containers)reference list based on the first vocabulary (Color) tags. So if someone clicks Red it will only list the second vocabulary (Containers) which has the term tagged as red.

How can I achieve this?

1 Answer 1


If you have to use two taxonomy vocabulary instead one, you can do the following.

  1. On the "color" vocabulary add entity reference to the "containers" vocabulary and for each color term set avaiable containers for it.
  2. Using Drupal.settings you give information about relations between terms (as an assocated array, for example) to browser so that it would use information in JavaScript.
  3. Add JQuery script, which intercepts a selection of a color term and delete redundant terms in the select box for containers. That is, for example, you have selected a color Green and JQuery script has immediately removed all elements from the select box for contaners, except "B" and "C".

You can add the JQuery script and send data to Drupal.setting using hook_form_alter for the node insert/edit form.

Of course, I'm not guarantee that this way is the rightest one, but if I were you I would try so at the beginning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.