FIO-7302: Prevent clearing the fields that does not exist on the current form revision if they were on the older one #1659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-7302
Description
What changed?
If there were some fields on the older form revisions that are not on the current one, and the user edits the submission done with an older revision, those fields are getting cleared during the validation (they are simply not set to the form data because there are no components with correspondent API keys).
With this fix after the validation is complete and right before replacing body's data with data that come from the validation, it will check if the form has revisions allowed and if there are some values paths in the original submission data (taken from the DB, not in the one that was sent fromt he client, so teh user won't be able to change those old fields values) and there are no correspondent components in the current form revision, and it will add those old fields values to the date that came from the validation.
Dependencies
https://github.com/formio/formio-server/pull/1397
How has this PR been tested?
I wrote an automates test, but this will be moved to the formio-server cuase it needs revisions allowed in order to work
Checklist: