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
|`choices`| Optional |`Object[]`|`-`| List of items to autosuggest. Required if not inside a ReferenceInput. |
60
-
|`create`| Optional |`Element`|`-`| A React Element to render when users want to create a new choice |
61
-
|`createLabel`| Optional |`string`|`ReactNode`| - | The label used as hint to let users know they can create a new choice. Displayed when the filter is empty. |
62
-
|`createItemLabel`| Optional |`string`|`(filter: string) => ReactNode`|`ra.action .create_item`| The label for the menu item allowing users to create a new choice. Used when the filter is not empty. |
63
-
|`debounce`| Optional |`number`|`250`| The delay to wait before calling the setFilter function injected when used in a ReferenceInput. |
64
-
|`emptyText`| Optional |`string`|`''`| The text to use for the empty element |
65
-
|`emptyValue`| Optional |`any`|`''`| The value to use for the empty element |
66
-
|`filterToQuery`| Optional |`string` => `Object`|`q => ({ q })`| How to transform the searchText into a parameter for the data provider |
67
-
|`isPending`| Optional |`boolean`|`false`| If `true`, the component will display a loading indicator. |
68
-
|`inputText`| Optional |`Function`|`-`| Required if `optionText` is a custom Component, this function must return the text displayed for the current selection. |
69
-
|`matchSuggestion`| Optional |`Function`|`-`| Required if `optionText` is a React element. Function returning a boolean indicating whether a choice matches the filter. `(filter, choice) => boolean`|
70
-
|`onChange`| Optional |`Function`|`-`| A function called with the new value, along with the selected record, when the input value changes |
71
-
|`onCreate`| Optional |`Function`|`-`| A function called with the current filter value when users choose to create a new choice. |
|`choices`| Optional |`Object[]`|`-`| List of items to autosuggest. Required if not inside a ReferenceInput. |
60
+
|`create`| Optional |`Element`|`-`| A React Element to render when users want to create a new choice |
61
+
|`createLabel`| Optional |`string`|`ReactNode`| - | The label used as hint to let users know they can create a new choice. Displayed when the filter is empty. |
62
+
|`createItemLabel`| Optional |`string`|`(filter: string) => ReactNode`|`ra.action .create_item`| The label for the menu item allowing users to create a new choice. Used when the filter is not empty. |
63
+
|`debounce`| Optional |`number`|`250`| The delay to wait before calling the setFilter function injected when used in a ReferenceInput. |
64
+
|`emptyText`| Optional |`string`|`''`| The text to use for the empty element |
65
+
|`emptyValue`| Optional |`any`|`''`| The value to use for the empty element |
66
+
|`filterToQuery`| Optional |`string` => `Object`|`q => ({ q })`| How to transform the searchText into a parameter for the data provider |
67
+
|`isPending`| Optional |`boolean`|`false`| If `true`, the component will display a loading indicator. |
68
+
|`inputText`| Optional |`Function`|`-`| Required if `optionText` is a custom Component, this function must return the text displayed for the current selection. |
69
+
|`matchSuggestion`| Optional |`Function`|`-`| Required if `optionText` is a React element. Function returning a boolean indicating whether a choice matches the filter. `(filter, choice) => boolean`|
70
+
|`offline`| Optional |`ReactNode`| - | What to render when there is no network connectivity when fetching the choices |
71
+
|`onChange`| Optional |`Function`|`-`| A function called with the new value, along with the selected record, when the input value changes |
72
+
|`onCreate`| Optional |`Function`|`-`| A function called with the current filter value when users choose to create a new choice. |
72
73
|`optionText`| Optional |`string`|`Function`|`Component`|`undefined`|`record Representation`| Field name of record to display in the suggestion item or function using the choice object as argument |
73
-
|`optionValue`| Optional |`string`|`id`| Field name of record containing the value to use as input value |
74
-
|`setFilter`| Optional |`Function`|`null`| A callback to inform the `searchText` has changed and new `choices` can be retrieved based on this `searchText`. Signature `searchText => void`. This function is automatically set up when using `ReferenceInput`. |
75
-
|`shouldRender Suggestions`| Optional |`Function`|`() => true`| A function that returns a `boolean` to determine whether or not suggestions are rendered. |
76
-
|`suggestionLimit`| Optional |`number`|`null`| Limits the numbers of suggestions that are shown in the dropdown list |
77
-
|`translateChoice`| Optional |`boolean`|`true`| Whether the choices should be translated |
74
+
|`optionValue`| Optional |`string`|`id`| Field name of record containing the value to use as input value |
75
+
|`setFilter`| Optional |`Function`|`null`| A callback to inform the `searchText` has changed and new `choices` can be retrieved based on this `searchText`. Signature `searchText => void`. This function is automatically set up when using `ReferenceInput`. |
76
+
|`shouldRender Suggestions`| Optional |`Function`|`() => true`| A function that returns a `boolean` to determine whether or not suggestions are rendered. |
77
+
|`suggestionLimit`| Optional |`number`|`null`| Limits the numbers of suggestions that are shown in the dropdown list |
78
+
|`translateChoice`| Optional |`boolean`|`true`| Whether the choices should be translated |
78
79
79
80
`<AutocompleteInput>` also accepts the [common input props](./Inputs.md#common-input-props).
80
81
@@ -370,6 +371,27 @@ const UserCountry = () => {
370
371
}
371
372
```
372
373
374
+
## `offline`
375
+
376
+
`<AutocompleteInput>` can display a custom message when it can't fetch the choices because there is no network connectivity, thanks to the `offline` prop.
|`sort`| Optional |`{ field: String, order: 'ASC' or 'DESC' }`|`{ field:'id', order:'DESC' }`| How to order the list of suggestions |
115
116
@@ -191,6 +192,26 @@ const filters = [
191
192
];
192
193
```
193
194
195
+
## `offline`
196
+
197
+
`<ReferenceInput>` can display a custom message when the referenced record is missing because there is no network connectivity, thanks to the `offline` prop.
198
+
199
+
```jsx
200
+
<ReferenceInput source="user_id" reference="users" offline="No network, could not fetch data"/>
201
+
```
202
+
203
+
`<ReferenceInput>` renders the `offline` element when:
204
+
205
+
- the referenced record is missing (no record in the `users` table with the right `user_id`), and
206
+
- there is no network connectivity
207
+
208
+
You can pass either a React element or a string to the `offline` prop:
209
+
210
+
```jsx
211
+
<ReferenceInput source="user_id" reference="users" offline={<span>No network, could not fetch data</span>} />
212
+
<ReferenceInput source="user_id" reference="users" offline="No network, could not fetch data"/>
213
+
```
214
+
194
215
## `parse`
195
216
196
217
By default, children of `<ReferenceInput>` transform the empty form value (an empty string) into `null` before passing it to the `dataProvider`.
0 commit comments