I'm experimenting with Phoenix 1.6 and LiveView, and trying to get my nested form/models to work as expected.
I have a schema with something like:
Parent
, Child
, where Parent has_many Children // Child belongs_to parent.
- I have a LiveView component with a form for Parent, which works well as expected.
- I render Parent.children with inputs_for, and the initial render (such for rendering Children that are already in the database) works fine.
I want to have something like an Add Child button, which will render another Child model in my form in the inputs_for block, that I can make changes to, and eventually submit.
I've tried a handful of things such as https://fullstackphoenix.com/tutorials/nested-model-forms-with-phoenix-liveview, but they either don't seem to work, or seem a bit outdated (referencing things that don't exist for me). The documentation helps a little bit, but doesn't seem to connect the Ecto bits with the LiveView bits that I'm looking for very well. Does anyone have thoughts/advice on the best way to achieve what I'm looking for? (I'm also a bit newer to Elixir/Phoenix/Ecto, so there may be things that I'm overlooking)