Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-8810: fixed an issue where user unables to resubmit (change) the form with several levels of nested forms with required fields #139

Conversation

TanyaGashtold
Copy link
Contributor

@TanyaGashtold TanyaGashtold commented Aug 20, 2024

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-8810

Description

What changed?

Sometimes the submission, that we pass to validator, does not have reference data for nested forms. The value of such nested forms looks like this { id: 'someID', data: {} }. I found at least 2 cases when it happens for PUT requests:

  1. when we want to change the submission of wizard form that have at least 1 page in the middle of the wizard with deeply nested forms. In this case the user can open 1st page and make changes, then go to the last page to submit the form. The middle page with deeply nested forms is not opened, it means that the nested form submission data is not loaded (it is lazy loaded from level 3). So, the server gets the empty data (just with reference ID) for such nested form.
  2. when we submit the webform with several levels of nested forms. In this case the full data (including all nested forms data) is validated as a part of the top form validation and then each nested form data(starting from the deepest one) is resaved. Once the deepest nested form value (No. 1) is resaved, the higher level nested form (No. 2) gets the form No.1 value as a reference to id without data. So, when the form No.2 is validated, its data does not have full submission object for form No. 1.

In both cases the submission data of deeply nested forms does not need the repeated validation:

  1. in case 1, the data of the deeply nested form is not changed and should not be resubmitted
  2. in case 2, the data of the deeply nested form was validated as a part of the top form validation + validated when the subform data is resaved on the server.

Noting all said, I have added the logic for eachComponentData that skips the iteration through the nested form data when the reference value is not attached.

Dependencies

formio/formio#1784

How has this PR been tested?

Manually + tests

Checklist:

  • I have completed the above PR template
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

…form with several levels of nested form with required fields
src/utils/formUtil.ts Outdated Show resolved Hide resolved
src/utils/formUtil.ts Outdated Show resolved Hide resolved
@johnformio
Copy link
Contributor

this looks good to me. Since it's a change to eachComponent, I'd like to get another reviewer to look at it as well.

@brendanbond brendanbond merged commit 7e1bebc into master Aug 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants