Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Fix SelectField definition #5923

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ import { SelectField } from 'react-admin';

| Prop | Required | Type | Default | Description |
| ----------------- | -------- | ----------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `choices` | Required | `Object[]` | - | List of items to show as options |
| `optionText` | Optional | `string | Function | Element` | 'name' | Name of the field to use to display the matching choice, or function returning that field name, or a React element to render for that choice |
| `optionValue` | Optional | `string` | 'id' | Name of the field to compare to the value to find the matching choice |
| `translateChoice` | Optional | `boolean` | `true` | Whether or not the choice text should be translated |
Expand All @@ -576,10 +577,10 @@ import { SelectField } from 'react-admin';

#### Usage

By default, the text is built by:
By default, the option is built by:

- finding a choice where the 'id' property equals the field value
- using the 'name' property and the option text
- finding a choice where the `id` property equals the field value
- using the `name` property as the option text

You can also customize the properties to use for the lookup value and text, thanks to the `optionValue` and `optionText` attributes.

Expand Down