ash_phoenix
ash_phoenix copied to clipboard
Support generic actions in `Form.for_action/3`
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