Set values to null if fields are hidden and not relevant

Set values to null if fields are hidden and not relevant


Hi all,

Let's take a radio button R1 with options Yes and No.
If you click on Yes, another radio button R2 appears with options A and B.
Then you click A.

But then you realize that you made a mistake and you wanted to click No on R1.
You click on No, R2 disappears because it is relevant only if R1 is Yes and you submit your form.

The problem is that R2 still has the value A, which is wrong because A is only valid if R1 is Yes.

How would you do to set it to null if this case happens ?

I did resolve it by developing a function which is called on Success and which sets all the values to Null if they are not relevant.

However as I have a lot of cases like this in my forms, I was wondering if someone had another simplest idea....

Many thanks ! (I hope I have been clear enough... let me know if that is not the case).
Guillaume