[BUG] Edit form does not save form after initial save
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
- Clone react-starterkit repo
- npm install
- Configure PROJECT_URL to your project
- npm start
- Login with admin user
- Create a new form
- Edit form and add one field
- Save form
- Add another field
- Save form
- Reload page
Expected behavior
Both fields are still present after reloading page
Observed behavior
- Save form (the newly added field is not present in xhr call to server)
- Reload form and the newly added field is gone
Example
Before adding second field (after step 7.)

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

UI and save request body

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.
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 @randallknutson Can you pls see why am I getting this error formio/react-app-starterkit#17
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!!!
can i check this?
can i check this?
@unnatijadhav Absolutely, please do!