From 20dd3939ec60adf01b02e65fb477a77cd5b79640 Mon Sep 17 00:00:00 2001 From: Mike Schell Date: Fri, 13 Dec 2024 13:20:09 -0500 Subject: [PATCH] fix form handling of "simple" union type (#220) --- lib/ash_admin/components/resource/form.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ash_admin/components/resource/form.ex b/lib/ash_admin/components/resource/form.ex index d772fcb..ccf26b5 100644 --- a/lib/ash_admin/components/resource/form.ex +++ b/lib/ash_admin/components/resource/form.ex @@ -1330,6 +1330,9 @@ defmodule AshAdmin.Components.Resource.Form do defp non_nil_form_field(form, [field | rest]) do case form[field] do + %Phoenix.HTML.FormField{form: %{data: %{value: %Ash.Union{type: type}}}} -> + type + %Phoenix.HTML.FormField{value: value} when not is_nil(value) -> value @@ -1678,7 +1681,7 @@ defmodule AshAdmin.Components.Resource.Form do case AshPhoenix.Form.submit(form, before_submit: before_submit, force?: true, - params: form_params + params: replace_new_union_stubs(form_params) ) do {:ok, result} -> redirect_to(socket, result)