Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use to_form :action as changeset action when passed #171

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Conversation

chrismccord
Copy link
Member

@chrismccord chrismccord commented Feb 5, 2024

@josevalim
Copy link
Member

Note this will require changing the mix.exs entry to:

  {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", optional: true},

Assuming we are launching phoenix_html v4.1.

Copy link
Contributor

@SteffenDE SteffenDE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the existing action here

{action, changeset} =
case Keyword.fetch(opts, :action) do
{:ok, action} -> {action, Map.put(changeset, :action, action)}
:error -> {nil, changeset}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:error -> {nil, changeset}
:error -> {changeset.action, changeset}

Comment on lines 4 to 8
{action, changeset} =
case Keyword.fetch(opts, :action) do
{:ok, action} -> {action, Map.put(changeset, :action, action)}
:error -> {nil, changeset}
end
Copy link
Member

@josevalim josevalim Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{action, changeset} =
case Keyword.fetch(opts, :action) do
{:ok, action} -> {action, Map.put(changeset, :action, action)}
:error -> {nil, changeset}
end
{action, opts} = Keyword.pop_lazy(opts, :action, fn -> changeset.action end)

@@ -11,6 +17,7 @@ if Code.ensure_loaded?(Phoenix.HTML) do
source: changeset,
impl: __MODULE__,
id: id,
action: action,
name: name,
errors: form_for_errors(changeset),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errors: form_for_errors(changeset),
errors: form_for_errors(action, changeset),

lib/phoenix_ecto/html.ex Outdated Show resolved Hide resolved
@chrismccord chrismccord merged commit 89a92b2 into main Feb 29, 2024
2 checks passed
@chrismccord chrismccord deleted the cm-form-action branch February 29, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants