Ash FrameworkAF
Ash Framework3y ago
15 replies
zimt28

Nested forms questions

I'm building a nested form with a single resource that can be nested as many times as the user wants. I cannot use manage_relationship/4 in my case so I'm using after_action hooks that don't seem to work with auto?: true.

1. Is there a way to get a behaviour similar to auto?: true? I'm currently specifying the forms option using a function that just generates recursive options for n levels deep and results in
forms: [
  direct_child_listings: [
    type: :list,
    resource: App.Listings.Listing,
    create_action: :create,
    forms: [
      direct_child_listings: [
        # ...
        forms: [
          direct_child_listings: [
            type: :list,
            resource: App.Listings.Listing,
            create_action: :create
          ]


2. Using Form.add_form, is there a way to get the path of a newly created form? In this case I could update the form to solve question 1.
3. It looks like all form levels track the params of their nested forms. When updating a form I cannot see the change on my page unless I run something like add_form again – this seems to update all params. Is there a way to refresh the params manually?
Form.update_form(socket.assigns.form, path, fn form ->
  Form.validate(form, %{"type" => "type", "subtype" => subtype})
end)
Was this page helpful?