Skip to content

Commit 21c344a

Browse files
committed
Add support for hidden inputs
Removed in 712ad7e, but it is useful not having to write `@field[:name].value` etc. and AI also makes mistakes there.
1 parent 2510360 commit 21c344a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

installer/templates/phx_web/components/core_components.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ defmodule <%= @web_namespace %>.CoreComponents do
151151
attr :type, :string,
152152
default: "text",
153153
values: ~w(checkbox color date datetime-local email file month number password
154-
search select tel text textarea time url week)
154+
search select tel text textarea time url week hidden)
155155

156156
attr :field, Phoenix.HTML.FormField,
157157
doc: "a form field struct retrieved from the form, for example: @form[:email]"
@@ -179,6 +179,12 @@ defmodule <%= @web_namespace %>.CoreComponents do
179179
|> input()
180180
end
181181

182+
def input(%{type: "hidden"} = assigns) do
183+
~H"""
184+
<input type="hidden" id={@id} name={@name} value={@value} {@rest} />
185+
"""
186+
end
187+
182188
def input(%{type: "checkbox"} = assigns) do
183189
assigns =
184190
assign_new(assigns, :checked, fn ->

0 commit comments

Comments
 (0)