Skip to content
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

Support generic actions in Form.for_action/3 #177

Open
cschmatzler opened this issue May 3, 2024 · 0 comments
Open

Support generic actions in Form.for_action/3 #177

cschmatzler opened this issue May 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@cschmatzler
Copy link

cschmatzler commented May 3, 2024

Is your feature request related to a problem? Please describe.
I'd like to have a generic way to create a form for all my resource actions. Right now, generic actions need to have their forms built manually since there's no generic Form.for_action/3.

Describe the solution you'd like
I'd like ash and ash_phoenix to support any action to be passed to Form.for_action/3, even if it's generic, When a generic action is passed, I should receive a form that has fields for all arguments of that generic actions. Obviously, there's no attributes to include.

Describe alternatives you've considered
It's not that difficult to generate a form myself with a schemaless Ecto changeset, but it's a different API instead of something more convenient.

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

# in resource
 actions do
   action :foo do
     argument :bar, :string, allow_nil?: false

     # do things....
   end
 end

# in controller
  form = AshPhoenix.Form.for_action(Resource, :foo)
  # ^ this should return a form instead of raising a CaseClauseError
  # alternatively add a `for_generic_action/3` but I'd like the ergonomics of that less
@cschmatzler cschmatzler added the enhancement New feature or request label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant