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
Replace phx-feedback-for in favor of used_input?/1 #5713
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d16d11
Replace phx-feedback-for in favor of used_errors
chrismccord d7f7318
used_input?/1
chrismccord 322d445
Rework form component
chrismccord af51f2e
Bump unreleased phoenix_html
chrismccord 7a42afe
Update installer/templates/phx_single/mix.exs
chrismccord d73a2a4
Update installer/templates/phx_umbrella/apps/app_name_web/mix.exs
chrismccord File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,17 +35,13 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web | |||||||||
{:ok, | ||||||||||
socket | ||||||||||
|> assign(assigns) | ||||||||||
|> assign_form(changeset)} | ||||||||||
|> assign_form(changeset, :validate)} | ||||||||||
end | ||||||||||
|
||||||||||
@impl true | ||||||||||
def handle_event("validate", %{"<%= schema.singular %>" => <%= schema.singular %>_params}, socket) do | ||||||||||
changeset = | ||||||||||
socket.assigns.<%= schema.singular %> | ||||||||||
|> <%= inspect context.alias %>.change_<%= schema.singular %>(<%= schema.singular %>_params) | ||||||||||
|> Map.put(:action, :validate) | ||||||||||
|
||||||||||
{:noreply, assign_form(socket, changeset)} | ||||||||||
changeset = <%= inspect context.alias %>.change_<%= schema.singular %>(socket.assigns.<%= schema.singular %>, <%= schema.singular %>_params) | ||||||||||
{:noreply, assign_form(socket, changeset, :validate)} | ||||||||||
end | ||||||||||
|
||||||||||
def handle_event("save", %{"<%= schema.singular %>" => <%= schema.singular %>_params}, socket) do | ||||||||||
|
@@ -63,7 +59,7 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web | |||||||||
|> push_patch(to: socket.assigns.patch)} | ||||||||||
|
||||||||||
{:error, %Ecto.Changeset{} = changeset} -> | ||||||||||
{:noreply, assign_form(socket, changeset)} | ||||||||||
{:noreply, assign_form(socket, changeset, :save)} | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
|
@@ -78,12 +74,12 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web | |||||||||
|> push_patch(to: socket.assigns.patch)} | ||||||||||
|
||||||||||
{:error, %Ecto.Changeset{} = changeset} -> | ||||||||||
{:noreply, assign_form(socket, changeset)} | ||||||||||
{:noreply, assign_form(socket, changeset, :save)} | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
defp assign_form(socket, %Ecto.Changeset{} = changeset) do | ||||||||||
assign(socket, :form, to_form(changeset)) | ||||||||||
defp assign_form(socket, %Ecto.Changeset{} = changeset, action) do | ||||||||||
assign(socket, :form, to_form(changeset, action: action)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
end | ||||||||||
|
||||||||||
defp notify_parent(msg), do: send(self(), {__MODULE__, msg}) | ||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my head we'd include
used_errors
directly in CoreComponent. I don't think we have a precedent for helper input functions in Phoenix.Component, do we?