UPDATED:
After discussion and consideration, the existing rules make sense. If a field is hidden during a process, with the 'ignore' rule set, the system discards any changes and preserves the pre-hide-rule value. That value may be blank, or have something from a previous non-hidden submission.
If you need or expect a field to be cleared once hidden, the method below can still be helpful to you.
ORIGINAL POST:
I don't know if anyone else has been noticing or otherwise being affected by it, but I thought I'd share my experience. I've found on our current version of Forms (Professional Version 11.0.2201.20436) that if a field hidden by field rules gets populated in one submission, then re-hidden in another, the value that was previously saved is still retained. This causes some havoc for some aspects of our process.
I have passed this along to my VAR, and they passed it along to Laserfiche, but I spent some time today building a javascript workaround and decided to share in case anyone else needed it.
By way of exposition, here are a few details that might help clarify this code:
- This function will run under any Submission action (Submit, Approve, Reject, or custom if you're using the same type of buttons).
- To ensure the code ran only where I wanted it, I had to go through and find all of the fields that were hidden conditionally (that I did NOT want to save the values of), then I added a class called 'conditionalHide' to each one.
- I have some true/false questions in the Form that I wanted to save the default 'false' (value = 0 for database purposes) if the field was hidden, so there's an bit of code for that.
Hopefully, with that bit of explanation, the rest of the code makes sense to you.
$(document).ready(function () { //Disable Autocomplete $('input').attr('autocomplete','off'); // Forms 11 is failing to follow the 'ignore field values' rule; clear hidden fields upon submission $('form input[type="Submit"]').on('click', function () { $('.conditionalHide').each(function(){ // See if the current element is hidden var isHidden = $(this).is(':hidden'); // if it is hidden, if (isHidden){ // See if the current element is a radio or checklist field var isRadioOrCheck = $(this).find('span.choice').length > 0; // Find the 'false' element for true/false radio buttons var $falseValue = $(this).find('span.choice input[value="0"]'); // if it is a radio button field, clear any and all selections if(isRadioOrCheck){ $(this).find('span.choice input').prop('checked',false); // for my fields where I want the default 'false' value, re-check that value if ($falseValue.length > 0) $falseValue.prop('checked',true); } // for everything else, just set the value to empty else{ $(this).find('input').val('').change(); $(this).find('select').val('').change(); $(this).find('textarea').val('').change(); } } }); // Finally, return 'true' to move Forms along with Submission return true; }); });