Skip to content

Commit 27dccfb

Browse files
authored
Merge pull request #10760 from marmelab/doc-optionValue-choices
[Doc] Document that `optionValue` only works with the `choices` prop
2 parents 853beff + 719de68 commit 27dccfb

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed

docs/AutocompleteArrayInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ const choices = [
495495
<AutocompleteArrayInput source="roles" choices={choices} optionValue="_id" />
496496
```
497497

498+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<AutocompleteArrayInput>` inside a `<ReferenceArrayInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
499+
498500
## `shouldRenderSuggestions`
499501

500502
When dealing with a large amount of `choices` you may need to limit the number of suggestions that are rendered in order to maintain acceptable performance. `shouldRenderSuggestions` is an optional prop that allows you to set conditions on when to render suggestions. An easy way to improve performance would be to skip rendering until the user has entered 2 or 3 characters in the search box. This lowers the result set significantly and might be all you need (depending on your data set).

docs/AutocompleteInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ const choices = [
568568
/>
569569
```
570570

571+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<AutocompleteInput>` inside a `<ReferenceInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
572+
571573
## `shouldRenderSuggestions`
572574

573575
When dealing with a large amount of `choices` you may need to limit the number of suggestions that are rendered in order to maintain acceptable performance. `shouldRenderSuggestions` is an optional prop that allows you to set conditions on when to render suggestions. An easy way to improve performance would be to skip rendering until the user has entered 2 or 3 characters in the search box. This lowers the result set significantly and might be all you need (depending on your data set).

docs/CheckboxGroupInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ const choices = [
214214
<CheckboxGroupInput source="roles" choices={choices} optionValue="_id" />
215215
```
216216

217+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<CheckboxGroupInput>` inside a `<ReferenceArrayInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
218+
217219
## `row`
218220

219221
By default, the checkboxes are displayed in a row. You can change that and let react-admin render one choice per row by setting the `row` prop to `false`:

docs/DualListInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ const choices = [
234234
<DualListInput source="roles" choices={choices} optionValue="_id" />
235235
```
236236

237+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<DualListInput>` inside a `<ReferenceArrayInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
238+
237239
## `sx`: CSS API
238240

239241
The `<DualListInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (see [the `sx` documentation](./SX.md) for syntax and examples). This property accepts the following subclasses:

docs/RadioButtonGroupInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ const choices = [
236236
/>
237237
```
238238

239+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<RadioButtonGroupInput>` inside a `<ReferenceInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
240+
239241
## `row`
240242

241243
By default, the radio buttons are displayed in a row. You can change that and let react-admin render one choice per row by setting the `row` prop to `false`:

docs/SelectArrayInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ const choices = [
377377
<SelectArrayInput source="roles" choices={choices} optionValue="_id" />
378378
```
379379

380+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<SelectArrayInput>` inside a `<ReferenceArrayInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
381+
380382
## `sx`: CSS API
381383

382384
The `<SelectArrayInput>` component accepts the usual `className` prop. You can also override many styles of the inner components thanks to the `sx` property (see [the `sx` documentation](./SX.md) for syntax and examples). This property accepts the following subclasses:

docs/SelectInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ const choices = [
470470
<SelectInput source="category" choices={choices} optionValue="_id" />
471471
```
472472

473+
**Note:** `optionValue` is only supported when the choices are provided directly via the `choices` prop. If you use `<SelectInput>` inside a `<ReferenceInput>`, the `optionValue` is always set to `id`, as the choices are records fetched from the related resource, and [records should always have an `id` field](./FAQ.md#can-i-have-custom-identifiersprimary-keys-for-my-resources).
474+
473475
## `resettable`
474476

475477
You can make the `SelectInput` component resettable using the `resettable` prop. This will add a reset button which will be displayed only when the field has a value.

0 commit comments

Comments
 (0)