React-admin: Can't create Entity after visiting Edit View of another resource

Created on 12 Sep 2018  路  2Comments  路  Source: marmelab/react-admin

Please do not submit support requests or "How to" questions here. For that, go to StackOverflow.

What you were expecting:
After visiting a custom edit view of a resource, I try to create an entity of another resource.

What happened instead:
I get an error message. The creation doesn't work as there is extraneous information in the payload related to the first resource.

Steps to reproduce:
Prerequisites:

  • You must have at least 2 resources, let's call them Resource1 and Resource2
  • You have a custom Edit view for Resource2, which doesn't contains inputs for all the fields of the entity. For example, if my entity is a Name, with 2 fields firstName and lastName, my edit view only contains an input for firstName.

Steps:

  • Go to the Edit view of Resource1
  • Go the Create view of Resource2, for example by going to the List view of Resource2 then clicking on "Create"
  • Fill in the required fields
  • Click on Create button at the bottom of the page
  • You see an error message

To be more precise, the payload of your POST request still has the lastName value of the previous resource, which results in an error.

Other information:
I investigated a bit and this seems to be due to redux-form behaviour, espacially this issue: https://github.com/erikras/redux-form/issues/2761. In short values are not removed from state when a field is not registered.

Environment

  • React-admin version: 2.2.0
  • Last version that did not exhibit the issue (if applicable): /
  • React version: 16.4.2
  • Browser:Chrome
  • Stack trace (in case of a JS error):

Thanks in advance for your help !

Most helpful comment

I upgraded my react-admin version and indeed it is solved :smile: Thank you !

All 2 comments

This has been fixed in https://github.com/marmelab/react-admin/releases/tag/v2.2.3. Can you confirm the version you are using ?

I upgraded my react-admin version and indeed it is solved :smile: Thank you !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

9747749366 picture 9747749366  路  3Comments

samanmohamadi picture samanmohamadi  路  3Comments

phacks picture phacks  路  3Comments

nicgirault picture nicgirault  路  3Comments

kdabir picture kdabir  路  3Comments