Skip to content

AshPhoenix.Form.for_action() needs a :params option for initial parameters like AshPhoenix.Form.for_create() does. #358

Closed
@iyjim

Description

@iyjim

Is your feature request related to a problem? Please describe.
When we create a form with Form.for_create(), we can have :params option for initial parameters. (Although this feature does not in documentation yet). But when we create a form with Form.for_action(), we don't have the :params option for initial parameters, that's not fair enough.

Describe the solution you'd like
Please make :params an option for Form.for_action().

Describe alternatives you've considered
The :prepare_source option can be used to feed initial parameters too, but :params option is more intuitive.

Express the feature either with a change to resource syntax, or with a change to the resource interface

params = %{containing: "hello"}
Post
  |> Form.for_action(:post_count, params: params) # <- with :params option

**The following test code can be added to form_test.exs in the 'describe "generic actions" do' block after this feature is implemented.

    test "generic actions can have forms with initial params" do
      params = %{containing: "hello"}

      assert 0 =
               Post
               |> Form.for_action(:post_count, params: params)
               |> Form.submit!(params: params)
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions