From 993ee8c208375fdcdde935030deae7758ca42bd3 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Fri, 14 May 2021 17:08:00 -0300 Subject: [PATCH 1/3] Improve readability of ReferenceInput examples --- docs/Inputs.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/Inputs.md b/docs/Inputs.md index 4881cfaa485..b5190fc634f 100644 --- a/docs/Inputs.md +++ b/docs/Inputs.md @@ -2061,27 +2061,30 @@ You can tweak how this component fetches the possible values using the `perPage` // by default, fetches only the first 25 values. You can extend this limit // by setting the `perPage` prop. + source="post_id" + reference="posts" + perPage={100} +> // by default, orders the possible values by id desc. You can change this order // by setting the `sort` prop (an object with `field` and `order` properties). + source="post_id" + reference="posts" + sort={{ field: 'title', order: 'ASC' }} +> // you can filter the query used to populate the possible values. Use the // `filter` prop for that. + source="post_id" + reference="posts" + filter={{ is_published: true }} +> ``` @@ -2092,9 +2095,10 @@ The child component may further filter results (that's the case, for instance, f ```jsx ({ title: searchText })}> + source="post_id" + reference="posts" + filterToQuery={searchText => ({ title: searchText })} +> ``` From 489de316540b0a2fe2b2220a64ba6886c2f96003 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Fri, 14 May 2021 17:09:43 -0300 Subject: [PATCH 2/3] Improve readability of ReferenceArrayInput examples --- docs/Inputs.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/Inputs.md b/docs/Inputs.md index b5190fc634f..e129820f256 100644 --- a/docs/Inputs.md +++ b/docs/Inputs.md @@ -1939,27 +1939,30 @@ You can tweak how this component fetches the possible values using the `perPage` // by default, fetches only the first 25 values. You can extend this limit // by setting the `perPage` prop. + source="tag_ids" + reference="tags" + perPage={100} +> // by default, orders the possible values by id desc. You can change this order // by setting the `sort` prop (an object with `field` and `order` properties). + source="tag_ids" + reference="tags" + sort={{ field: 'title', order: 'ASC' }} +> // you can filter the query used to populate the possible values. Use the // `filter` prop for that. + source="tag_ids" + reference="tags" + filter={{ is_published: true }} +> ``` From 5294f66a4245385fd296b1246d3bba56df7f1b95 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Fri, 14 May 2021 17:13:57 -0300 Subject: [PATCH 3/3] Fix description --- docs/Fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Fields.md b/docs/Fields.md index 54669708a75..4960f72673d 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -988,7 +988,7 @@ Also, you can filter the query used to populate the possible values. Use the `fi This [Enterprise Edition](https://marmelab.com/ra-enterprise) component fetches a list of referenced records by lookup in an associative table, and passes the records down to its child component, which must be an iterator component. -For instance, here is how to fetch the authors related to a book record by matching book.id to book_authors.post_id, then matching book_authors.author_id to authors.id, and then display the author last_name for each, in a : +For instance, here is how to fetch the authors related to a book record by matching book.id to book_authors.post_id, then matching book_authors.author_id to authors.id, and then display the author last_name for each, in a ``: ```jsx import * as React from 'react';