You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Features.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,7 +257,7 @@ Let's be realistic: Many developers focus on features first and don't have much
257
257
React-admin provides **components that look pretty good out of the box**, so even if you don't spend time on the UI, it won't look bad (unless you try hard). React-admin uses [Material UI](https://mui.com/material-ui/getting-started/), which is a React implementation of the [Material Design](https://material.io/) guidelines, the most battle-tested design system.
By default, `<ReferenceArrayFieldBase>` renders its children even when the related records list is empty. You can customize what is rendered by providing your own component via the `empty` prop:
You can also have `<ReferenceArrayFieldBase>` render nothing in that case by setting the prop to `null`:
156
+
157
+
```jsx
158
+
<ReferenceArrayFieldBase
159
+
source="tag_ids"
160
+
reference="tags"
161
+
empty={null}
162
+
>
163
+
...
164
+
</ReferenceArrayFieldBase>
165
+
```
166
+
167
+
## `error`
168
+
169
+
By default, `<ReferenceArrayFieldBase>` renders its children even when an error occurs while fetching the related records. You can customize what is rendered by providing your own component via the `error` prop:
You can also have `<ReferenceArrayFieldBase>` render nothing in that case by setting the prop to `null`:
188
+
189
+
```jsx
190
+
<ReferenceArrayFieldBase
191
+
source="tag_ids"
192
+
reference="tags"
193
+
error={null}
194
+
>
195
+
...
196
+
</ReferenceArrayFieldBase>
197
+
```
198
+
132
199
## `render`
133
200
134
201
Alternatively to `children`, you can pass a `render` function prop to `<ReferenceArrayFieldBase>`. The `render` prop will receive the `ListContext` as its argument, allowing to inline the rendering logic.
@@ -176,12 +243,44 @@ For instance, to render only tags that are 'published', you can use the followin
176
243
```
177
244
{% endraw %}
178
245
246
+
## `loading`
247
+
248
+
By default, `<ReferenceArrayFieldBase>` renders its children even while fetching the related records. You can customize what is rendered by providing your own component via the `loading` prop:
You can also have `<ReferenceArrayFieldBase>` render nothing in that case by setting the prop to `null`:
267
+
268
+
```jsx
269
+
<ReferenceArrayFieldBase
270
+
source="tag_ids"
271
+
reference="tags"
272
+
loading={null}
273
+
>
274
+
...
275
+
</ReferenceArrayFieldBase>
276
+
```
277
+
179
278
## `offline`
180
279
181
280
By default, `<ReferenceArrayFieldBase>` renders nothing when there is no connectivity and the records haven't been cached yet. You can provide your own component via the `offline` prop:
**Tip**: If the records are in the Tanstack Query cache but you want to warn the user that they may see an outdated version, you can use the `<IsOffline>` component:
| `children` | Optional | `Element` | - | One or several elements that render a list of records based on a `ListContext` |
92
+
| `children` | Optional\* | `Element` | - | One or several elements that render a list of records based on a `ListContext` |
93
93
| `render` | Optional\* | `(ListContext) =>Element` | - | Function that receives a `ListContext` and returns an element |
94
-
| `debounce` | Optional\* | `number` | 500 | debounce time in ms for the `setFilters` callbacks |
94
+
| `debounce` | Optional | `number` | 500 | debounce time in ms for the `setFilters` callbacks |
95
95
| `empty` | Optional | `ReactNode` | - | Element to display when there are no related records. |
96
+
| `error` | Optional | `ReactNode` | - | The component to render when an error occurs while fetching the related records |
96
97
| `filter` | Optional | `Object` | - | Filters to use when fetching the related records, passed to `getManyReference()` |
98
+
| `loading` | Optional | `ReactNode` | - | The component to render while fetching the related records |
97
99
| `offline` | Optional | `ReactNode` | - | Element to display when there are no related records because of lack of network connectivity. |
98
100
| `perPage` | Optional | `number` | 25 | Maximum number of referenced records to fetch |
99
101
| `queryOptions` | Optional | [`UseQuery Options`](https://tanstack.com/query/v3/docs/react/reference/useQuery) | `{}` | `react-query` options for the `getMany` query |
@@ -177,6 +179,38 @@ Use `empty` to customize the text displayed when there are no related records.
177
179
</ReferenceManyFieldBase>
178
180
```
179
181
182
+
## `error`
183
+
184
+
By default, `<ReferenceManyFieldBase>` renders its children when an error occurs while fetching the related records. You can customize what is rendered by providing your own component via the `error` prop:
You can also have `<ReferenceManyFieldBase>` render nothing in that case by setting the prop to `null`:
203
+
204
+
```jsx
205
+
<ReferenceManyFieldBase
206
+
reference="books"
207
+
target="author_id"
208
+
error={null}
209
+
>
210
+
...
211
+
</ReferenceManyFieldBase>
212
+
```
213
+
180
214
## `filter`: Permanent Filter
181
215
182
216
You can filter the query used to populate the possible values. Use the `filter` prop for that.
@@ -195,6 +229,38 @@ You can filter the query used to populate the possible values. Use the `filter`
195
229
196
230
{% endraw %}
197
231
232
+
## `loading`
233
+
234
+
By default, `<ReferenceManyFieldBase>` renders its children while fetching the related records. You can customize what is rendered by providing your own component via the `loading` prop:
Copy file name to clipboardExpand all lines: ReferenceManyInput.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,6 +74,8 @@ const ProductEdit = () => (
74
74
75
75
**Tip**: `<ReferenceManyInput>` cannot be used with `undoable` mutations. You have to set `mutationMode="optimistic"` or `mutationMode="pessimistic"` in the parent `<Edit>`, as in the example above.
76
76
77
+
**Tip**: `<SimpleFormIterator>` uses the `disableReordering` prop in this example because the `variants` resource doesn't support reordering. If your reference table does have a `rank` column, you can leave sorting controls on (see [the `rankSource` section](#ranksource) for details).
|`source`| Optional |`string`|`id`| Name of the field that carries the identity of the current record, used as origin for the relationship |
87
89
|`filter`| Optional |`Object`| - | Filters to use when fetching the related records, passed to `getManyReference()`|
88
90
|`perPage`| Optional |`number`| 25 | Maximum number of referenced records to fetch |
91
+
|`rankSource`| Optional |`string`| - | Name of the field used to store the rank of each item. When defined, it enables reordering of the items. |
89
92
|`sort`| Optional |`{ field, order }`|`{ field: 'id', order: 'DESC' }`| Sort order to use when fetching the related records, passed to `getManyReference()`|
90
93
|`defaultValue`| Optional |`array`| - | Default value of the input. |
91
94
|`validate`| Optional |`Function`|`array`| - | Validation rules for the array. See the [Validation Documentation](./Validation.md) for details. |
@@ -202,6 +205,31 @@ By default, react-admin restricts the possible values to 25 and displays no pagi
202
205
</ReferenceManyInput>
203
206
```
204
207
208
+
### `rankSource`
209
+
210
+
`<SimpleFormIterator>` provides controls to reorder the items in the list. If the related records have a numeric rank field, you can enable the reordering feature by setting the `rankSource` prop.
211
+
212
+
for example, if the variants have a `rank` field, you can set the `rankSource` prop like this:
213
+
214
+
```jsx
215
+
<ReferenceManyInput
216
+
reference="variants"
217
+
target="product_id"
218
+
rankSource="rank"
219
+
>
220
+
<SimpleFormIterator>
221
+
<TextInput source="sku"/>
222
+
<SelectInput source="size" choices={sizes} />
223
+
<SelectInput source="color" choices={colors} />
224
+
<NumberInput source="stock" defaultValue={0} />
225
+
</SimpleFormIterator>
226
+
</ReferenceManyInput>
227
+
```
228
+
229
+
Now the variants will be ordered by rank, and whenever the user changes the order of the items, `<ReferenceManyInput>` will update the `rank` field of each item accordingly.
230
+
231
+
Note that `<SimpleFormIterator>` doesn't have the `disableReordering` prop in that case, to display the up/down controls.
232
+
205
233
## `reference`
206
234
207
235
The name of the resource to fetch for the related records.
Copy file name to clipboardExpand all lines: Theming.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: "Theming"
8
8
React-admin applications use a neutral style by default. You will probably want to customize the look and feel to match your branding, or your end users preferences. Don't worry! You can customize the look and feel of pretty much everything in react-admin.
Copy file name to clipboardExpand all lines: doc/5.11/Features.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,7 +257,7 @@ Let's be realistic: Many developers focus on features first and don't have much
257
257
React-admin provides **components that look pretty good out of the box**, so even if you don't spend time on the UI, it won't look bad (unless you try hard). React-admin uses [Material UI](https://mui.com/material-ui/getting-started/), which is a React implementation of the [Material Design](https://material.io/) guidelines, the most battle-tested design system.
0 commit comments