Skip to content

Commit af2e75d

Browse files
ponychickenSteffenDE
authored andcommitted
Add documentation of how to use <.input type="select">
Fixes phoenixframework/phoenix_live_view#3197 Closes #5764.
1 parent 488798d commit af2e75d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

installer/templates/phx_web/components/core_components.ex

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,22 @@ defmodule <%= @web_namespace %>.CoreComponents do
140140
141141
## Examples
142142
143-
<.input field={@form[:email]} type="email" />
144-
<.input name="my-input" errors={["oh no!"]} />
143+
```heex
144+
<.input field={@form[:email]} type="email" />
145+
<.input name="my-input" errors={["oh no!"]} />
146+
```
147+
148+
## Select type
149+
150+
When using `type="select"`, you must pass the `options` and optionally
151+
a `value` to mark which option should be preselected.
152+
153+
```heex
154+
<.input field={@form[:user_type]} type="select" options={["Admin": "admin", "User": "user"]} />
155+
```
156+
157+
For more information on what kind of data can be passed to `options` see
158+
[`options_for_select`](https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#options_for_select/2).
145159
"""
146160
attr :id, :any, default: nil
147161
attr :name, :any

0 commit comments

Comments
 (0)