Skip to content

Commit

Permalink
keep original form action when none is provided to to_form
Browse files Browse the repository at this point in the history
Fixes #3493.

When using `<.form for={@Form} :let={f}>`, the `f` form would have no
action set, even if the original `@form` has one. This led to errors
not being displayed on nested forms.
  • Loading branch information
SteffenDE committed Nov 11, 2024
1 parent 18d3f6a commit c66efff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/phoenix_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ defmodule Phoenix.Component do

{_as, options} = Keyword.pop(options, :as)
{errors, options} = Keyword.pop(options, :errors, data.errors)
{action, options} = Keyword.pop(options, :action)
{action, options} = Keyword.pop(options, :action, data.action)
options = Keyword.merge(data.options, options)

%Phoenix.HTML.Form{
Expand Down
3 changes: 3 additions & 0 deletions test/phoenix_component_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ defmodule Phoenix.ComponentUnitTest do

form = to_form(base, action: :validate)
assert form.action == :validate

form = to_form(%{base | action: :validate})
assert form.action == :validate
end
end

Expand Down

0 comments on commit c66efff

Please sign in to comment.