Skip to content
Open
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
33 changes: 32 additions & 1 deletion docs/reference/field-types/radio.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A `radio` field allows a list of options where a user can select one value.
## Module field definition

```javascript

// Configuring the `animalType` field in a module's `fields.add` subsection:
animalType: {
label: 'Type of animal',
Expand Down Expand Up @@ -34,6 +35,33 @@ animalType: {
}
```

```javascript

// Configuring an alignment field using `buttons` presentation and icons
alignment: {
label: 'Alignment',
type: 'radio',
buttons: true,
choices: [
{
tooltip: 'Left',
value: 'left',
icon: 'format-align-left-icon'
},
{
tooltip: 'Center',
value: 'center',
icon: 'format-align-center-icon'
},
{
tooltip: 'Right',
value: 'right',
icon: 'format-align-right-icon'
}
]
}
```

## Settings

### Required
Expand All @@ -57,6 +85,7 @@ animalType: {
|`hidden` | Boolean | `false` | If `true`, the field is hidden |
|`required` | Boolean | `false` | If `true`, the field is mandatory |
|`readOnly` | Boolean | `false` | If `true`, prevents the user from editing the field value |
|`buttons` | Boolean | `false` | If `true`, presents the radios as a set of buttons |

<!-- TODO: The following settings are likely to return, but are not yet implemented. -->
<!-- |contextual | Boolean | false | If `true`, it will prevent the field from appearing in the editor modal | -->
Expand All @@ -74,7 +103,9 @@ The value(s) of the followed field(s) will be used to create an object with prop
The `choices` setting in `checkboxes`, `radio`, or `select` fields configures the options that a user will see in the interface and the values that the server will allow in validation. The `choices` value is an array of objects with `label` and `value` properties, or a string ending with `()` representing a [`method(self)`](../module-api/module-overview#methods) in your module. See below for more [details](#choices).

- `value` is used in the field's database value
- `label` is the more human-readable version used in interfaces
- `label` is the more human-readable version used in interfaces. Can be omitted when using the `buttons` presentation
- `icon` (Optional) the name of an icon to pair with the choice
- `tooltip` (Optional) a string that will appear as a tooltip on the choice

## Populating `choices` dynamically {#choices}

Expand Down