Dependent lists
Hello. I need help.
There is a taxonomy dictionary "teams" with sub-levels "countries," and within the countries, there are lists of "cities," and further, there are "districts."
I need to create three lists where you first select a "country." Based on the selected country, a list of "cities" should be generated, then you select a city, and a list of districts will be formed that can also be selected.&stag2834> The main thing is that when the selections in lists 1 and 2 change, the contents of the lists should update accordingly.
I tried to do this using Hierarchical Select, but I need to store three fields (not just the last one) in the node: Country, City, District.&stag2839>
Because all of them are mandatory!!! for further sorting and manipulation with nodes.
Also, Hierarchical Select is not suitable because you can only select the first level and that's it...
Perhaps it's possible to force the selection of all three levels of the dictionary, but I still need to store all the listed values "country," "city," "district" somewhere.
I see a solution like this:
implementation of dependent lists:
create three dropdown menus of the required content type.
Create a taxonomy dictionary with the necessary tree structure Country-City-District.
Make changes to the type_material--node.tpl.php
and wait for the page to load.&stag2856>
Fill the first list of countries from the taxonomy tree (make a selection of the first level).
Then, write a hook to catch the selection in the first list,
which will populate the second list with terms of the second level whose parent is the selected element in the first list.
In total, I need to write two hooks for changing the selection in the first and second lists.
What do I need to write these hooks?
After that, I need to enable adding new terms (to lists 2 and 3) directly from the form.&stag2867>
But I don't know how to write all of this.&stag2869>
Please provide the clearest answer possible.
This question has puzzled many newcomers, and I haven't found a clear answer for such an implementation anywhere.