Edit/Create and listing on same page

In Phoenix generally all the pages for create, update and edit are shown different. We pass the data to the template based on the action a user want to perform.

To list all entities we use render as:

render(conn, "index.html", refunds: refunds)

And to create entity we pass changeset:

render(conn, "new.html", changeset: changeset)

I want to show the create/edit for on same page where all entity are listed as follows:

How can this be achieved in single template as both actions need different struct while using render?

refunds = …
changeset = …
render(conn, "index.html", refunds: refunds, changeset: changeset)
1 Like

Thanks, I too did the same. I was hoping that if there is another way to do the same.