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

How to work with ReferenceArrayField / ReferenceArrayInput #13

Open
henrik-d opened this issue Nov 24, 2019 · 1 comment
Open

How to work with ReferenceArrayField / ReferenceArrayInput #13

henrik-d opened this issue Nov 24, 2019 · 1 comment

Comments

@henrik-d
Copy link

henrik-d commented Nov 24, 2019

Hi,
first of all thanks for sharing the dataProvider. I have a problem with Many-to-Many relationsships.

A Book has many Authors.
An Author writes many Books.

In React Admin in the books resource I want to display / edit the related authors using ReferenceArrayField / ReferenceArrayInput. The problem is that React Admin expects the following format:

// book  as required by React Admin
{
    "title": "Book Title",
    "auhors": [2,4,5] //just the authorIds
}

Whereas Nest-Crud generates and requires a list of objects with at least idto update the relationship.

// book  as required by Nest CRUD
{
    "title": "Book Title",
    "auhors": [{"id": 2}, {"id": 4}, {"id": 5}] //objects
}

What would you recommend? Can this issue be solved in the dataProvider or elsewhere in React Admin? Or is it best to solve it on the server side, e.g. with an interceptor?

Thanks!

@pkramarczyk
Copy link

Hey!
I had the same issue. Just found this issue in ra repository and managed to make it work:
marmelab/react-admin#4125

Notice that it was fixed in the 3.0.4 version!

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

No branches or pull requests

2 participants