AshPhoenix (ash_phoenix v0.3.1) View Source

See the readme for the current state of the project

Link to this section Summary

Link to this section Functions

Link to this function

add_embed(query, path, outer_form_name, add \\ %{})

View Source

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.

Link to this function

hiding_errors?(changeset)

View Source
Link to this function

remove_embed(changeset, path, outer_form_name)

View Source

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
Link to this function

to_form_error(exception)

View Source
Link to this function

transform_errors(changeset, transform_errors)

View Source