-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Update handling-relations.md with an example of ReferenceArrayInput #1144
base: 2.5
Are you sure you want to change the base?
Conversation
It took me plenty of hours to get nested objects with referenceArrayInput running. By a lucky hit i found the fix for it! (https://html.developreference.com/article/11019200/How+to+reuse+subresource+data+for+referenced+inputs+in+React-admin%3F) Also i struggeled with the referenceInput. Please at those special cases for nested.
@@ -326,6 +326,15 @@ const ReviewsEdit = props => ( | |||
> | |||
<AutocompleteInput optionText="title" /> | |||
</ReferenceInput> | |||
// or | |||
<ReferenceInput | |||
source="book.@id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using the format
prop is clearer than having this source.
... | ||
|
||
<ReferenceArrayInput source="books" reference="books_reference" label="Books" sort={{field: 'title', order: 'ASC'}} | ||
format={v => (v ? v.map(i => (i["@id"] 11? i["@id"] : i)) : [])}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format={v => (v ? v.map(i => (i["@id"] 11? i["@id"] : i)) : [])}> | |
format={v => (v ? v.map(i => (i["@id"] || i)) : [])}> |
<EditGuesser {...props}> | ||
... | ||
|
||
<ReferenceArrayInput source="books" reference="books_reference" label="Books" sort={{field: 'title', order: 'ASC'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you indent properly?
|
||
Let's say `useEmbedded` parameter is set to `true` and you have nested a nested objects array you want to use in an ReferenceArrayInput. ReferenceArrayInput expects an array of ids. In this case you have to tell it, where it finds those ids. This is done via "format" | ||
|
||
```javascript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to add this example above than to write again the example.
@@ -345,3 +354,42 @@ export default () => ( | |||
``` | |||
|
|||
The autocomplete field should now work properly! | |||
|
|||
Let's say `useEmbedded` parameter is set to `true` and you have nested a nested objects array you want to use in an ReferenceArrayInput. ReferenceArrayInput expects an array of ids. In this case you have to tell it, where it finds those ids. This is done via "format" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say `useEmbedded` parameter is set to `true` and you have nested a nested objects array you want to use in an ReferenceArrayInput. ReferenceArrayInput expects an array of ids. In this case you have to tell it, where it finds those ids. This is done via "format" | |
Let's say `useEmbedded` parameter is set to `true` and you have nested an array of objects you want to use in a `ReferenceArrayInput`. `ReferenceArrayInput` expects an array of ids. In this case, you have to tell it where to find those ids. This is done by using the `format` prop. |
It took me plenty of hours to get nested objects with referenceArrayInput running. By a lucky hit i found the fix for it! (https://html.developreference.com/article/11019200/How+to+reuse+subresource+data+for+referenced+inputs+in+React-admin%3F)
Also i struggeled with the referenceInput. Please at those special cases for nested. Feel free to edit :-)