From 21c344a6b78dcca689aaf2debf8371cfebb2ccba Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Tue, 2 Sep 2025 10:37:02 +0200 Subject: [PATCH] Add support for hidden inputs Removed in https://github.com/phoenixframework/phoenix/commit/712ad7ede061b4716d6b17fc3b6bb7e4858d5ebe, but it is useful not having to write `@field[:name].value` etc. and AI also makes mistakes there. --- installer/templates/phx_web/components/core_components.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/installer/templates/phx_web/components/core_components.ex b/installer/templates/phx_web/components/core_components.ex index 36a8df1aa5..d0206a9c2f 100644 --- a/installer/templates/phx_web/components/core_components.ex +++ b/installer/templates/phx_web/components/core_components.ex @@ -151,7 +151,7 @@ defmodule <%= @web_namespace %>.CoreComponents do attr :type, :string, default: "text", values: ~w(checkbox color date datetime-local email file month number password - search select tel text textarea time url week) + search select tel text textarea time url week hidden) attr :field, Phoenix.HTML.FormField, doc: "a form field struct retrieved from the form, for example: @form[:email]" @@ -179,6 +179,12 @@ defmodule <%= @web_namespace %>.CoreComponents do |> input() end + def input(%{type: "hidden"} = assigns) do + ~H""" + + """ + end + def input(%{type: "checkbox"} = assigns) do assigns = assign_new(assigns, :checked, fn ->