Skip to content

Make :params available for for_action() with test and add :params' document for all for_* actions #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/ash_phoenix/form/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
]
]

Expand Down
11 changes: 10 additions & 1 deletion test/form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down