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/3.0/fields/select.md
+38-14
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,6 @@ The `Select` field renders a `select` field.
11
11
field :type, as::select, options: { 'Large container': :large, 'Medium container': :medium, 'Tiny container': :tiny }, display_with_value:true, placeholder:'Choose the type of the container.'
12
12
```
13
13
14
-
## Options
15
-
16
14
<Optionname="`options`">
17
15
18
16
A `Hash` representing the options that should be displayed in the select. The keys represent the labels, and the values represent the value stored in the database.
@@ -25,7 +23,26 @@ The options get cast as `ActiveSupport::HashWithIndifferentAccess` objects if th
25
23
26
24
#### Possible values
27
25
28
-
`{ 'Large container': :large, 'Medium container': :medium, 'Tiny container': :tiny }` or any other `Hash`.
26
+
-`{ 'Large container': :large, 'Medium container': :medium, 'Tiny container': :tiny }` or any other `Hash`.
27
+
- A lambda function that returns a `Hash` (computed options)
28
+
29
+
### Computed options
30
+
31
+
You may want to compute the values on the fly for your `Select` field. You can use a lambda for that where you have access to the `record`, `resource`, `view`, and `field` properties where you can pull data off.
The output value must be a supported [`options_for_select`](https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_for_select) value.
29
46
</Option>
30
47
31
48
<Optionname="`enum`">
@@ -75,8 +92,6 @@ end
75
92
76
93
<Optionname="`include_blank`">
77
94
78
-
## Include blank
79
-
80
95
The `Select` field also has the `include_blank` option. That can have three values.
81
96
82
97
If it's set to `false` (default), it will not show any blank option but only the options you configured.
@@ -103,20 +118,29 @@ end
103
118
`nil`, `true`, `false`, or a string to be used as the first option.
104
119
</Option>
105
120
106
-
## Computed options
121
+
<Optionname="`multiple`">
107
122
108
-
You may want to compute the values on the fly for your `Select` field. You can use a lambda for that where you have access to the `record`, `resource`, `view`, and `field` properties where you can pull data off.
123
+
<VersionReqversion="3.17.3" />
109
124
110
-
```ruby{5-7}
125
+
If it's set to `false` (default), it will only allow selecting a single option from the list.
126
+
127
+
If it's set to `true`, it will enable multiple selections, allowing users to choose more than one option at a time.
0 commit comments