I want to make the options for a (secondary) term reference autocomplete field dependent on the values chosen in another (primary) autocomplete term reference field. How can I limit the options in the secondary term reference field?
I have two vocabularies called chapter and sub-chapters. In the sub-chapters vocabulary, I have an additional term reference field linking each sub-chapter to the chapter in the chapter vocabulary. (I wanted to use two separate vocabularies, rather than a single hierarchical vocabulary to make it easier to use separate exposed views filters).
On my main content form, I want to limit the sub-chapters available in the autocomplete field to the values chosen in the primary chapters autocomplete field.
I have looked at many different modules for achieving this and haven't found any that will work with my scenario so need to write some code to achieve this. I need to use autocomplete fields as there are so many terms to choose from for both the primary and secondary fields. I have been using the autocomplete deluxe widget for the primary field but I can just use the standard autocomplete widget if this makes it easier.
Can anyone give me a rough outline of the basic code I would need to write in order to achieve this?
I guess there will need to be an update of the options of the secondary term reference field whenever the values are altered in the primary term reference field using AJAX?