-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
ReferenceField inside Edit component is not requesting getMany #4124
Comments
I'm having the same issue. I don't see any requests firing. |
In order to fix the issue, we need to reproduce it. Please share a codesandbox showing the issue. |
@djhi I created a sandbox here: https://codesandbox.io/s/cocky-star-fiti9?fontsize=14&hidenavigation=1&theme=dark If you click on the animal in the list, it takes you to the edit form. You can see that the ReferenceField does not load the data, but the ReferenceInput for the exact same data is loaded. If you look at the console, you will see that no getMany is called for the ReferenceField. (Comment out the ReferenceInput to make this really obvious.) |
Confirmed and reproduced, thanks for the CodeSandbox. |
What you were expecting:
ReferenceField in Edit component causes a getMany request to be sent to data provider for the referenced resource, and the value is displayed by the child field.
What happened instead:
No getMany request is sent to the data provider for the reference resource.
Steps to reproduce:
Create a vanilla react-admin project by following the first few steps of the tutorial.
Create a list and edit form for a resource and add the resource under the Admin component.
In the edit form, add a ReferenceField component with a child TextField. Add the referenced resource under the Admin component.
In your data provider, add some console.log statements so you can see which requests react-admin makes to the data provider.
Run the project. Go to the browser window that opened and also open developer tools to javascript console.
Select an item from the list in the app to view the edit form.
Look in the console output and see that no getMany request is made.
Replace the ReferenceField with a ReferenceInput, and the TextField with a TextInput.
Save the changes, and the app reloads. In the console, you will now see both a getMany and a getList for the referenced resource.
Apparently, ReferencField inside an Edit component does not generate a getMany request as advertised: "Such components are used in the List view, but you can also use them in the Edit and Create views for read-only fields....This component fetches a single referenced record (using the GET_MANY REST method), and displays one field of this record." (https://marmelab.com/react-admin/Fields.html)
Related code:
Example edit form:
In this example the source is
id
because the referenced resource has a one-to-one relationship to the edited resource.Confirmed that I have the corresponding
investment
andaumLast
resources defined as children of my Admin component. Also confirmed that the corresponding query directly on the database returns data.Other information:
Environment
The text was updated successfully, but these errors were encountered: