Ash FrameworkAF
Ash Framework5mo ago
5 replies
Rutgerdj

Child form is not automatically added when a `:union` type attribute has a `value` of `nil`

Im trying to create a Form using Form.for_update on a resource that has a :union type attribute where the value is nil:

form = AshPhoenix.Form.for_update(
  %Resource{union: %Ash.Union{type: :custom, value: nil}},
  forms: [auto?: true]
)

# form.forms => %{}


With this the form.forms is empty. I would expect the forms to have a union key because I need a form to edit the union.

Adding a form using AshPhoenix.Form.add_form(form, :union) adds the form, but that doesnt have the correct type set in the union, it takes the first type from the constraints it seems.
Was this page helpful?