AshPhoenix (ash_phoenix v0.3.1) View Source
See the readme for the current state of the project
Link to this section Summary
Functions
A utility to support "add" buttons on embedded types used in forms.
A utility to support "remove" buttons on embedded types used in forms.
Link to this section Functions
A utility to support "add" buttons on embedded types used in forms.
To use, simply pass in the form name of the embedded form as well as the name of the primary/outer form.
# In your template, inside a form called `:change`
<button phx-click="append_thing" phx-value-path={{form.path}}>
</button>
# In the view/component
def handle_event("append_thing", %{"path" => path}, socket) do
changeset = add_embed(socket.assigns.changeset, path, "change")
{:noreply, assign(socket, changeset: changeset)}
end
You can also pass a specific value to be added, to seed the changes in a customized way.
By default, %{}
is used.
A utility to support "remove" buttons on embedded types used in forms.
To use, simply pass in the form name of the embedded form as well as the name of the primary/outer form.
# In your template, inside a form called `:change`
<button phx-click="remove_thing" phx-value-path={{form.path}}>
</button>
# In the view/component
def handle_event("remove_thing", %{"path" => path}, socket) do
changeset = remove_embed(socket.assigns.changeset, path, "change")
{:noreply, assign(socket, changeset: changeset)}
end