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: docs/AutocompleteInput.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ The form value for the source must be the selected value, e.g.
67
67
|`isPending`| Optional |`boolean`|`false`| If `true`, the component will display a loading indicator. |
68
68
|`inputText`| Optional |`Function`|`-`| Required if `optionText` is a custom Component, this function must return the text displayed for the current selection. |
69
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 |
70
71
|`onChange`| Optional |`Function`|`-`| A function called with the new value, along with the selected record, when the input value changes |
71
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 |
@@ -340,6 +341,27 @@ const UserCountry = () => {
340
341
}
341
342
```
342
343
344
+
## `offline`
345
+
346
+
`<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