Ash FrameworkAF
Ash Framework6mo ago
6 replies
rtorresware

Losing entries for nested forms on validate

To reproduce:
- Have form for update action with manage_relationship(:resource, type: :direct_control).
- Have a button to add new form:
  def handle_event("add-form", %{"path" => path}, socket) do
    form = AshPhoenix.Form.add_form(socket.assigns.edit_form, path, params: %{})

    {:noreply, assign(socket, :edit_form, form)}
  end

- click button, form is added, everything works fine.
- make a change in the form, phx-change event is handled:
  def handle_event("update_edit_form", params, socket) do
    {:noreply, update(socket, :edit_form, &AshPhoenix.Form.validate(&1, params))}
  end

- the nested forms disappear!
Solution
I think you're missing pattern matching the actual params out
Was this page helpful?