I would like to create a customizable filter widget that can be used to filter a view on a page. One type of filter uses taxonomy terms. While I can easily create a list of terms, I find I cannot create a list of vocabulary NAMES to choose from for the filter.

Ultimately, I'd like to iterate through the terms of the chosen vocabulary name and display that list of terms. So, in summary, create a widget that users can choose from a list of vocabulary names. Once that is selected, display the list of terms of that vocabulary name on the page. Is this possible?

I've tried so many different ways using views, entity references, etc but cannot get a list of vocabulary names in a field.

2 Answers 2


As the vocabulary is an entity, you can find his name id (taxonomy_vocabulary) in Drupal\taxonomy\Entity\Vocabulary.

To load all the available vocabularies you can use the following code:

$vocabularies = \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->loadMultiple();

To create the dependent taxonomy terms select I recommend you to take a look at the ajax examples in the Examples for Developers module.


Since this wasn't directly accessible via twig, I went the route of creating a view of the taxonomy terms. This worked well to create an entity reference widget which was then used to define a field in a content type.

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.