Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Updating/Clearing a field based on another field selection #82

Closed
stephenreddek opened this issue Feb 10, 2017 · 3 comments
Closed

Updating/Clearing a field based on another field selection #82

stephenreddek opened this issue Feb 10, 2017 · 3 comments

Comments

@stephenreddek
Copy link
Contributor

I have a form with about 10 different fields. The options for two select fields (lets call them color and model for example) are dependent on the value of another field (say make). I'm currently able to change the options given to the selects based on the value of the field. My problem is that I can't find a good way to set the current selected value of color or model whenever the make is updated. I know that I could break encapsulation, inspect the update message, and, when the make changes, set the selected color and model to defaults/selected by calling initialize again and using the getFieldAsString for all of the fields and substituting the appropriate values in the list. However, this not a desirable approach. Is there a good way to achieve this kind of functionality? Thank you for any guidance! If there's a general feature to work on here, I would also be willing to take a crack at implementing it and submitting a PR.

@etaque
Copy link
Owner

etaque commented Feb 12, 2017

Hi,
The only way I see is to add a kind of post-update step where you take the form as input, look at fields, do the update and re-validate if needed. That would add a bit of boilerplate, but I don't see any better way at the moment. A space that needs exploration!

@stephenreddek
Copy link
Contributor Author

Hi,
Thank you for your time! By update and re-validate, do you mean re-initialize with the manipulated data?

@etaque
Copy link
Owner

etaque commented Mar 22, 2017

Hi,
Sorry for the response delay. Re-initialize would be too much, just setting a field by generating and applying the message for field update, Input String InputType FieldValue in Form.Msg. Might be a bit verbose I fear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants