Ash FrameworkAF
Ash Framework3y ago
27 replies
gvanders

Nested embedded Resource Form

I have an embedded resource which contains multiple other embedded resources. When I use AshPhoenix.Form.for_update with forms: [auto?: true], the form created does not contain information about any of the embedded resources other than the first key.

Right now I am adding the missing data like so
    update_form =
      AshPhoenix.Form.for_update(styles, :update,
        api: Timshel.Ash.Api,
        forms: [auto?: true]
      )
    |> AshPhoenix.Form.add_form(:background, type: :update, data: styles.background)
    |> AshPhoenix.Form.add_form(:text, type: :update, data: styles.text)
    |> AshPhoenix.Form.add_form(:border, type: :update, data: styles.border)
    |> AshPhoenix.Form.add_form(:size, type: :update, data: styles.size)


Is there something I have to set up in the update action of the root level embedded resource?

Additionally, when adding the form in assigns after validation, the diff sent over the wire is huge. Any tips on reducing the payload for large forms? Splitting up something in some way?
Was this page helpful?