Im debugging a form of ours that consists of multiple sections. Most of these section starts with a simple yes/no question think of like a toggle button(standard_main_question in the schema below).
The state of the toggle(true or false) is used to show additional questions using the Rules API as written in the docs.
However if I choose to toggle yes and answer those questions but then decide to toggle no.
Those hidden questions(standard_main_question_additional_question_1 and standard_main_question_additional_question_2) are still being submitted to the backend and they still remain inside the redux store even though they are now hidden due to I changed my toggle to no.
I did go through the list of issues on Github and found something related(I think).
I know it can be hard without the actual schema but I can post this here as well. Whats the best way to do so? A gist or directly in the spectrum?
Hi @steffen25(steffen25), we don’t remove data by design, we just show or hide the controls. Usually the experience is not that great when the user enters some data, triggers a hide rule (for example by clicking a check box), then untriggers it (unchecking the checkbox) and now has to reenter all of their data again.
Usually I recommend just removing the unwanted data before further processing it, e.g. before sending it to a REST endpoint.
Of course you can still achieve this effect if you want to:
Register a custom renderer for the control which effectively hides/unhides the other controls. There not only set your own data but also remove the data you don’t want to keep, or
Register a middleware which listens to these specific data changes you are interested in and also removes the data you don’t want to keep