I have a taxonomy with 2 levels
City1
-Park1
-Park2
-Park3
City2
-Park4
-Park5
-Park6
In my form, I created a field that links to this taxonomy with an autocomplete widget. I also have a second field where the user chooses the city.
I would like to dynamically change the autocomplete value depending on the selected city. Which means if the user selects City1, the autocomplete will only filter through the values under City1.
After checking the form I've found that the widget entity_autocomplete
have an attribute #selection_handler
. Will it be possible to change this handler and somehow send the value of the selected city?
I think there should be an easier approach. Creating a custom autocomplete field based on a textfield
doesn't seem like a good solution since it will not have (or I will need to do it manually) all the error handling and entity links.
Any suggestions ?