diff --git a/lib/ash_phoenix/form/auto.ex b/lib/ash_phoenix/form/auto.ex index 401f304..d2c8d08 100644 --- a/lib/ash_phoenix/form/auto.ex +++ b/lib/ash_phoenix/form/auto.ex @@ -224,7 +224,6 @@ defmodule AshPhoenix.Form.Auto do Keyword.update!(opts, :forms, fn forms -> Keyword.put(forms, :_join, resource: relationship.through, - data: &get_join(&1, &2, relationship), create_action: action.name ) end) diff --git a/test/form_test.exs b/test/form_test.exs index 198f2f6..3d3e6e6 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -60,6 +60,28 @@ defmodule AshPhoenix.FormTest do assert hd(inputs_for(form, :post)).errors == [{:text, {"is required", []}}] end + test "nested errors are set on the appropriate form after submit, even if no submit actually happens" do + form = + Comment + |> Form.for_create(:create, + forms: [ + post: [ + resource: Post, + create_action: :create + ] + ] + ) + |> Form.add_form(:post, params: %{}) + |> Form.validate(%{"text" => "text", "post" => %{}}) + |> Form.submit(Api) + |> elem(1) + |> form_for("action") + + assert form.errors == [] + + assert hd(inputs_for(form, :post)).errors == [{:text, {"is required", []}}] + end + test "nested forms submit empty values when not present in input params" do form = Comment