I have an edit form for a Post record, and I'm listing the Reviews associated with that Post in a ReferenceManyField/DataGrid (ie <ReferenceManyField target="post_id" reference="reviews">
). Each Review has the foreign key post_id
in the DB. This is all working fine, I have an edit and delete button for each Review row.
I need to add a 'Create Review' button for the Post form, such that the post_id
field in the Create Review form is pre-populated with the current id
of the Post. I'm not very expert in React/Redux.
As @Gildas has suggested above, you need a custom component for that.
1) A custom create button that routes to a create page for the review. For this you should look at how the React Router Link component documentation as well as how Admin On Rest would allocate a route for instance /:reviewId/create
2) Create a custom input component that will prefill the ID when loaded. This should be part of the location key in the props passed to your page. Ask additional questions as comments and I will try and answer them.
React and Redux are really simple things when you get the hang of them
This is not possible directly for now: you'll have to create a custom component for that: documentation.
Someone tried to address this issue and even supplied a pull-request. Hopefully we'll be able to merge it soon: https://github.com/marmelab/admin-on-rest/pull/744
Edit: this might help https://marmelab.com/blog/2018/07/09/react-admin-tutorials-form-for-related-records.html