react-app-starterkit icon indicating copy to clipboard operation
react-app-starterkit copied to clipboard

[BUG] Edit form does not save form after initial save

Open 7er opened this issue 5 years ago • 6 comments

Environment

  • Hosting type

    • [x] Form.io
    • [ ] Local deployment
      • Version:
  • React app starter kit git commit: 52ae0d4e5f1cc75ddbf310b186c4b90ecdbc55dd

  • Formio.js version: [email protected]

  • Frontend framework: [email protected]

  • Browser: chrome

  • Browser version: 81

Steps to Reproduce

  1. Clone react-starterkit repo
  2. npm install
  3. Configure PROJECT_URL to your project
  4. npm start
  5. Login with admin user
  6. Create a new form
  7. Edit form and add one field
  8. Save form
  9. Add another field
  10. Save form
  11. Reload page

Expected behavior

Both fields are still present after reloading page

Observed behavior

  1. Save form (the newly added field is not present in xhr call to server)
  2. Reload form and the newly added field is gone

Example

Before adding second field (after step 7.)

Skjermbilde 2020-05-05 kl  16 29 25

Add second field and save it (step 8 and 9)

UI and save response Skjermbilde 2020-05-05 kl  16 34 43

UI and save request body Skjermbilde 2020-05-05 kl  16 35 55

7er avatar May 05 '20 14:05 7er

We've seen this issue from time to time and thought we had it fixed. The issue is that the connection with the scoped variable within the react app gets lost during the update process when react refreshes the props. This needs to be investigated again to see if something has broken again recently and how to fix it.

randallknutson avatar May 05 '20 20:05 randallknutson

I've localized the bug to the implementation of FormEdit.getDerivedStateFromProps. When adding the second field/component to the form this function overwrites this.state.form with this.props.form.

7er avatar May 08 '20 16:05 7er

@7er @randallknutson Can you pls see why am I getting this error formio/react-app-starterkit#17

rahulseth625 avatar Jan 27 '21 12:01 rahulseth625

I'm getting this issue. I notice on page loads, it triggers the onChange with empty values of the submission.data object

const onFormioChange = async (submission: any) => {
        const formData = new FormData();
        formData.append('form_values', JSON.stringify(submission.data))

        const updateFormValues = await fetch(`/form/update`, {
            method: 'POST',
            body: formData
        })
    }
    
    return <Form
        onChange={onFormioChange}
    />

this needs to be fixed ASAP!!!

handhikadj avatar Mar 09 '23 16:03 handhikadj

can i check this?

unnatijadhav avatar Aug 02 '23 04:08 unnatijadhav

can i check this?

@unnatijadhav Absolutely, please do!

lane-formio avatar Jun 27 '24 20:06 lane-formio