Skip to content

Commit

Permalink
Options for select (#263)
Browse files Browse the repository at this point in the history
* options for select

* bold

* drop internal invert

* version req
  • Loading branch information
Paul-Bob authored Jul 29, 2024
1 parent 3a197ab commit a8698d4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/3.0/dynamic-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,48 @@ dynamic_filter :first_name,
suggestions: -> { ["Avo", "Cado", params[:extra_suggestion]] }
```
</Option>

<Option name="`options`">
<VersionReq version="3.10.10" />

Customize the options **for select type filters**. **This is available only for select type filters** and determines the options visible in the select dropdown.

##### Default value

Fetched from field if bond to a field or `[]`

#### Possible values

An array or hash where the key-value pairs represent the options.

- If a hash is provided, the key is the option label and the value is the option value.
- If an array is provided, the array elements are used as both the option value and the option label.

##### Usage examples
###### Array
```ruby{3}
dynamic_filter :version,
type: :select,
options: ["Label 1", "Label 2"]
```

###### Hash (with invert)
```ruby{3-6}
dynamic_filter :version,
type: :select,
options: {
value_1: "Label 1",
value_2: "Label 2"
}.invert
```

###### Hash (without invert)
```ruby{3-6}
dynamic_filter :version,
type: :select,
options: {
"Label 1" => :value_1,
"Label 2" => :value_2
}
```
</Option>

0 comments on commit a8698d4

Please sign in to comment.