Firstly, props to the Zach and the rest of the Ash team for their incredible work and dedication in making the Ash Framework and extensions freely available to the community. Have bought the Ash book and am going through it.
It occurred to me that alot of projects required complex data input by users which is best done in multi-step forms.
In Vanilla Phoenix and Liveview I’ve used changesets mapped to individual fields and live components with a form for each field validating their own input - submitting sends to the parent liveview the params which are built up as the user progresses throught the form and finally the parent liveview handles storing the data.
Wondering if there is an Ash recommended way of doing this?
New to Ash so at the start of the learning curve and am not at the stage where I totally grasp the capabilities of the framework,
Apologies if I’ve missed something totally obvious with this question.
Many thanks.
You can do something very similar using resources without a data layer.
i.e
defmodule Phase1 do
use Ash.Resource
attributes do
...
end
end
defmodule Phase2 do
use Ash.Resource
attributes do
...
end
end
defmodule Phase3 do
use Ash.Resource
attributes do
...
end
end
and you can then have a form for each of those. When you submit, you’ll just get back a validated struct.
Additonally, you could use embedded attributes on a single resource, i.e
defmodule MultistepForm do
use Ash.Resource
attributes do
attribute :phase1, Phase1
attribute :phase2, Phase2
end
end
defmodule Phase1 do
use Ash.Resource, data_layer: :embedded
attributes do
...
end
end
defmodule Phase2 do
use Ash.Resource, data_layer: :embedded
attributes do
...
end
end
3 Likes

Zach - thank you. I’m in Oz - can’t believe I got an answer so quickly from whatever timezone you’re in!
I apologise that this question may have been very basic but it was an itch I needed to scratch and your answer is incredibly helpful in opening up my understanding of Ash - I really think that Ash is definitely the way forward in developing robust applications in elixir.
Once again, I’m very grateful for your help.
1 Like
Not basic at all
welcome to the community!
2 Likes