mix ash_form_builder.gen.form
(AshFormBuilder v0.3.0)
View Source
Generates a self-contained Phoenix LiveView (or LiveComponent) that renders
an AshFormBuilder.FormComponent wired to the given Ash resource.
Usage
$ mix ash_form_builder.gen.form MyApp.Accounts.User
$ mix ash_form_builder.gen.form MyApp.Accounts.User --action update
$ mix ash_form_builder.gen.form MyApp.Accounts.User --out lib/my_app_web/live
$ mix ash_form_builder.gen.form MyApp.Accounts.User --component
Arguments
Resource— Fully-qualified Ash resource module (e.g.MyApp.Accounts.User)
Options
--action/-a(default:create) — Ash action to generate the form for--out/-o(default:lib/<otp_app>_web/live) — Output directory--component/-c— Generate a LiveComponent instead of a LiveView
Generated File
For a LiveView, the generated file mounts AshPhoenix.Form, renders the
AshFormBuilder.FormComponent, and handles the {:form_submitted, ...} message
sent on success.
For a LiveComponent, the generated file exposes an idiomatic update/2 +
render/1 pair ready to drop into a parent LiveView.
Example
$ mix ash_form_builder.gen.form MyApp.Blog.Post --action create
* created lib/my_app_web/live/post_form_live.ex
Add to your router:
live "/posts/new", MyAppWeb.PostFormLive