Making all hidden fields optional
Hi all!
This is related to a previous question that I've asked, but I think I narrowed things down quite a bit. I have a script (Fragment) that runs on submission that scans the form and makes all hidden-required fields optional, that way the form will submit as long as all of the visible required fields are filled. This script worked really well on PDF forms, but I'm transitioning to .xdp (HTML5 rendered) forms.
I'm having 1 key issue. Whenever I try to change a hidden field to optional, the script crashes. My initial fix was to, in the script code, make the field visible, make it optional, then make it hidden. This briefly worked but now is broken for some unknown reason. It makes the user push submit twice before submitting, obviously not great from a user experience standpoint.
Is there a known way to make a hidden field optional in a script? This seems like something that lots of people would want to do, but I can't find anything about it which leads me to worry that maybe I'm missing something obvious. Thank you for any advice you can give!
Respectfully,
John