Skip to content

Commit

Permalink
Add documentation of how to use <.input type="select">
Browse files Browse the repository at this point in the history
  • Loading branch information
ponychicken committed Feb 27, 2025
1 parent 8f2770e commit bb630e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions installer/templates/phx_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,18 @@ defmodule <%= @web_namespace %>.CoreComponents do
for more information. Unsupported types, such as hidden and radio,
are best written directly in your templates.
## Examples
## Basic Examples
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
## Select type
When using `type="select"`, you must pass the `options` and optionally
a `value` to mark which option should be preselected.
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
For more information on what kind of data can be passed to `options` see
[`options_for_select`](https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#options_for_select/2)
"""
attr :id, :any, default: nil
attr :name, :any
Expand Down
14 changes: 11 additions & 3 deletions priv/templates/phx.gen.live/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,18 @@ defmodule <%= @web_namespace %>.CoreComponents do
for more information. Unsupported types, such as hidden and radio,
are best written directly in your templates.
## Examples
## Basic Examples
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
## Select type
When using `type="select"`, you must pass the `options` and optionally
a `value` to mark which option should be preselected.
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
For more information on what kind of data can be passed to `options` see
[`options_for_select`](https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#options_for_select/2)
"""
attr :id, :any, default: nil
attr :name, :any
Expand Down

0 comments on commit bb630e3

Please sign in to comment.