diff --git a/lib/ash_phoenix/form/form.ex b/lib/ash_phoenix/form/form.ex index 5ac42de..cd78cba 100644 --- a/lib/ash_phoenix/form/form.ex +++ b/lib/ash_phoenix/form/form.ex @@ -285,6 +285,13 @@ defmodule AshPhoenix.Form do tenant: [ type: :any, doc: "The current tenant. Passed through to the underlying action." + ], + params: [ + type: :any, + default: %{}, + doc: """ + The initial parameters to use for the form. This is useful for setting up a form with default values. + """ ] ] diff --git a/test/form_test.exs b/test/form_test.exs index fecebd6..1f52a59 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -20,10 +20,19 @@ defmodule AshPhoenix.FormTest do assert 0 = Post - |> Form.for_action(:post_count, params: params) + |> Form.for_action(:post_count) |> Form.validate(params) |> Form.submit!(params: params) end + + test "generic actions can accept initial params" do + params = %{containing: "hello"} + + assert 0 = + Post + |> Form.for_action(:post_count, params: params) + |> Form.submit!(params: nil) + end end describe "drop_param" do