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

[3.11] SaveButton inside FormWithRedirect component throws error #5691

Closed
WiXSL opened this issue Dec 18, 2020 · 10 comments · Fixed by #5780
Closed

[3.11] SaveButton inside FormWithRedirect component throws error #5691

WiXSL opened this issue Dec 18, 2020 · 10 comments · Fixed by #5780
Assignees
Labels

Comments

@WiXSL
Copy link
Contributor

WiXSL commented Dec 18, 2020

The custom form shown here:
https://marmelab.com/react-admin/CreateEdit.html#custom-form-component
No longer works with react-admin v3.11

I copy-paste the above sample as the Post form in the following sandbox:
https://codesandbox.io/s/charming-mahavira-kuphi?file=/src/posts/PostCreate.js

  1. Create a new Post
  2. You get the error TypeError: Cannot read property 'save' of undefined

Environment

  • React-admin version: 3.11
  • Last version that did not exhibit the issue (if applicable): 3.10.4
  • React version: 17.0.1
  • Browser: Google Chrome latest
@AnkitaGupta111
Copy link
Contributor

@WiXSL follow documentation properly,enclose FormWithRedirect Component within Create tags and replace resource and source props in Input fields with correct value

@WiXSL
Copy link
Contributor Author

WiXSL commented Dec 21, 2020

My example wasn't the best. But I have code like that, that was working before verion 3.11.
I'll re-do the example.
Basically I have a mui Dialog with a FormWithRedirect inside that is opened from a List bulkActionButtons's button.

@fzaninotto
Copy link
Member

Using FormWithRedirect outside of Create or Edit isn't something we encourage. Use react-final-form's <Form> component for such cases.

@etienne-bondot
Copy link

etienne-bondot commented Dec 23, 2020

Same here, three views on my side were broken after 3.11 update. Changing from the react-admin SimpleForm to the Form component from react-final-form and reimplementing handleSubmit fixed them. But this is a dangerous breaking change introduced for many users here. They are some SO post talking about it.

@fzaninotto
Copy link
Member

I'm sorry that you were bitten by this as well, but it's not a breaking change if the feature was never documented.

@alextaymx
Copy link

@fzaninotto , the DEMO examples are not updated to this latest changes

@fzaninotto
Copy link
Member

@alextaymx Not sure what you're talking about. Can you be more specific?

@WiXSL
Copy link
Contributor Author

WiXSL commented Jan 4, 2021

#5738 has just been merged, which solves the problem (At least the one I reported) at least until the next mayor release. By then it would be my responsibility to upgrade my code to use SaveContext of course.

@alextaymx
Copy link

@fzaninotto , if i'm not mistaken, in the demo repo, the Review Edit part https://github.com/marmelab/react-admin/blob/master/examples/demo/src/reviews/ReviewEdit.tsx is using SimpleForm without Edit component, this is where the error pops out.

@fzaninotto
Copy link
Member

@alextaymx You're right. Since @WiXSL's patch, it only logs a warning, but it should be changed. I'll update the demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants