Passing all form data to custom servlet
I have a form with multiple panels and various other things going on. I have it set up to save to a database for drafts and submissions. Due to the nature of the form, we need to keep it as a draft to maintain editability for the nature of this project.
We're looking to add a way to generate an email of the form data when a particular button is pushed. I've got it set up to transmit the form data as JSON to a custom servlet to be iterated over. Unfortunately, generating the JSON data for the form without knowing all of the form field names is causing some issues. In other forms, I just reference the fieldName.value to pass the value through as a set parameter name. This time, though, the form could be modified at any point with new options added or removed. I need to be able to pass everything through to the servlet regardless of changes.
My only real problem here is that when I change the values of the form fields, the name of the field goes from referencing the field name I defined to the SOM position in a way that is not useful when I go to parse the data.
When logging the JSON data to console, I get back the following where the form name I provided for the first line is status1 and the second is notes1. I currently have 18 status and notes fields, with the number at the end increasing, but once the value is changed, I'm not getting statusX or notesX back anymore. Is there a way to get a more useful name for each field after data has been updated without being able to reference the field by name specifically?