I am working with the new Ash Framework book from PragPro but create the project from scratch.
I generated a form_component via mix ash_phoenix.gen.live --domain Tuneshg.Music --resource Tuneshg.Music.Artist --resourceplural artists
At first, I used the form = AshPhoenix.Form.for_create()
function to create a new artist.
Later on I learned, that I could create these functions via AshPhoenix-Extensions.
That got me: form = Tuneshg.Music.form_to_create_artist()
When using this new function, the app crashed, when validating the input.
Deeper inspection showed, that the params ended to the validate function differ.
When using
AshPhoenix.Form.for_create():
HANDLE EVENT "validate" in TuneshgWeb.ArtistLive.Index
Component: TuneshgWeb.ArtistLive.FormComponent
Parameters: %{"_target" => ["artist", "biography"], "artist" => %{"biography" => "my_biography", "name" => "my_name"}}
When using
Tuneshg.Music.form_to_create_artist():
HANDLE EVENT "validate" in TuneshgWeb.ArtistLive.Index
Component: TuneshgWeb.ArtistLive.FormComponent
Parameters: %{"_target" => ["form", "name"], "form" => %{"_unused_biography" => "", "_unused_name" => "", "biography" => "", "name" => "m"}}
Why do these two ways produce different params?
Is this intentional or is it a bug?
And if it is intentional, what is the intention?
Thanks for your reply, Heiko