Hi guys,
Here is my use case: I have three fields: Region, Customer, and Country. In a ticket, the user will pick a region, which will present the corresponding customers. Based on the customer chosen, a specific country will be mapped.
For the most part, this works well.
However, what I can't figure out is, how do I clear values based on whether another field is changed? For example,
I can set customer field to "None" if region is null :
if (region.getValue() == null) {
region.setError("You need to choose a region.")
customer.setFormValue(-1)
}...
But what I really want is the same behavior if either Customer or Region is modified.
For example, let's say I have a Region of "Region1", a customer of "Customer3", and a country of "Mexico". If Customer changes, country should remap to new country. If Region changes (for example to say, Region2), country should be changed to None, and Customer should also be changed to None.
Any tips? *Note* -- When I pick a region, it isn't a one-to-one mapping, which is why I am passing the FieldOptions. Once a specific option from FieldOptions is chosen, that is what maps to Country in a 1-1 relationship.