Say there are two select elements with dynamic options (via an options alter hook, sourced from an external resource): A and B. There is also a datasource that provides a relationship that determines the options in B that should shown when a particular selection in A is chosen.
The source data for each element in addition to the relationship data source is not able to be predicted or controlled by Drupal.
A Options at a particular instant
| name | code | | Group 1 | 1 | | Group 2 | 2 | | Group 3 | 3 |
B options at a particular instant
| name | code | | Thing 1 | 1 | | Thing 2 | 2 | | Thing 3 | 3 |
The relationships at any given time.
| group | thing | | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 1 | | 2 | 2 | | 3 | 3 |
So if group 1 is selected for A, then things 1, 2, and 3 should be options for B
If group 2 is selected for A, then things 1 and 2 should be options for B
If group 3 is selected, then only thing 3 should be an option for 3.
We are currently implementing this requirement through the core FAPI and ajax callbacks, but would like to covert it to use Webforms.
What would be the recommended approach to take in order to solve this with Webforms? Please bear in mind that modifying the source data is not an option, as it is not able to be predicted nor controlled by our unit and adjustments must be reflected in realtime.