When you have a hierarchy structure of taxonomy, the default selection list is not quite user friendly because it list out all the parent and child terms. Assume with want to attach a country and city terms to the Article content type. The most straight forward way is create one vocabulary with some countries as parent terms and some cities as child terms like the following list.
It turns on that when someone is adding a new article, he may select either a country term or a city term. That is probably not what we want.
A better solution is provided by the Hierarchy Select module which we have talked about it in the past.
Drupal 7 – Mutiliple selection list for taxonomy using Hierarchical Select
1. Download and enable the module.
2. Create a vocabulary called Country with the following 2 terms.
3. Create a separate vocabulary and name it as City, add a new term reference called field_country so now each city term has to select a specific country term.
4. Create the following city terms.
- London (field_country set to England)
- Lyon (field_country set to France)
- Manchester (field_country set to England)
- Paris (field_country set to France)
5. Add the existing field_country to the Article content type as usual.
6. Add a new term reference field with field name field_city and in the setting page, check the Limit this field’s options according to matching field values option as depicted in the following picture.
For views, you can expose both the Country and City term filters. So it should work with Views without any problem. But currently there is a bug in the module and the AJAX update of the exposed city term (child term) does not work in Views. Here is the tracking issue in the Reference field option limit project.
Error in views on adding a field with (option limit) as filter criteria