diff --git a/docs/Fields.md b/docs/Fields.md index f069929175c..f306973b2ef 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -472,13 +472,13 @@ However, in some cases (e.g. inside a ``), you may not want the ``` -**Tip**: `` sets `translateChoice` to `false` by default. +**Tip**: `` sets `translateChoice` to `true` by default. ## `` -This component fetches a single referenced record (using the `GET_MANY` REST method), and displays one field of this record. That's why a `` must always have a child ``. +This component fetches a single referenced record (using the `dataProvider.getMany()` REST method), and displays one field of this record. That's why a `` must always have a child ``. -For instance, here is how to fetch the `post` related to `comment` records, and display the `title` for each: +For instance, here is how to fetch the `user` related to `post` records, and display the `name` for each: ```jsx import React from 'react'; @@ -488,9 +488,10 @@ export const PostList = (props) => ( - + + ); @@ -506,15 +507,15 @@ With this configuration, `` wraps the user's name in a link to t ```jsx - - + + ``` To change the link from the `` page to the `` page, set the `link` prop to "show". ```jsx - + ``` @@ -522,7 +523,7 @@ To change the link from the `` page to the `` page, set the `link` p By default, `` is sorted by its `source`. To specify another attribute to sort by, set the `sortBy` prop to the according attribute's name. ```jsx - + ``` @@ -531,7 +532,7 @@ You can also prevent `` from adding link to children by setting ```jsx // No link - + ``` @@ -540,38 +541,38 @@ You can also use a custom `link` function to get a custom path for the children. ```jsx // Custom path - `/my/path/to/${reference}/${record.id}`}> + `/my/path/to/${reference}/${record.id}`}> ``` -**Tip**: React-admin accumulates and deduplicates the ids of the referenced records to make *one* `GET_MANY` call for the entire list, instead of n `GET_ONE` calls. So for instance, if the API returns the following list of comments: +**Tip**: React-admin accumulates and deduplicates the ids of the referenced records to make *one* `dataProvider.getMany()` call for the entire list, instead of n `dataProvider.getOne()` calls. So for instance, if the API returns the following list of posts: ```js [ { id: 123, - body: 'Totally agree', - post_id: 789, + title: 'Totally agree', + user_id: 789, }, { id: 124, title: 'You are right my friend', - post_id: 789 + user_id: 789 }, { id: 125, title: 'Not sure about this one', - post_id: 735 + user_id: 735 } ] ``` -Then react-admin renders the `` with a loader for the ``, fetches the API for the related posts in one call (`GET http://path.to.my.api/posts?ids=[789,735]`), and re-renders the list once the data arrives. This accelerates the rendering, and minimizes network load. +Then react-admin renders the `` with a loader for the ``, fetches the API for the related users in one call (`GET http://path.to.my.api/users?ids=[789,735]`), and re-renders the list once the data arrives. This accelerates the rendering, and minimizes network load. ## `` -This component fetches a list of referenced records by reverse lookup of the current `record.id` in other resource (using the `GET_MANY_REFERENCE` REST method). You can specify the target field name, i.e. the field name of the current record's id in the other resource, using the required `target` field. The result is then passed to an iterator component (like `` or ``). The iterator component usually has one or more child `` components. +This component fetches a list of referenced records by reverse lookup of the current `record.id` in other resource (using the `dataProvider.getManyReference()` REST method). You can specify the target field name, i.e. the field name of the current record's id in the other resource, using the required `target` field. The result is then passed to an iterator component (like `` or ``). The iterator component usually has one or more child `` components. For instance, here is how to fetch the `comments` related to a `post` record by matching `comment.post_id` to `post.id`, and then display the `author.name` for each, in a ``: @@ -691,7 +692,7 @@ Where `[1, 23, 4]` refer to ids of `tag` resources. http://myapi.com/tags?id=[1,23,4] ``` -**Tip**: `` fetches the related resources using the `GET_MANY` REST method, so the actual HTTP request depends on your REST client. +**Tip**: `` fetches the related resources using the `dataProvider.getMany()` REST method, so the actual HTTP request depends on your REST client. Once it receives the related resources, `` passes them to its child component using the `ids` and `data` props, so the child must be an iterator component (like `` or ``). The iterator component usually has one or more child `` components.