Passing variable through multiple templates

The html generator uses the new to render form.

I want to pass down a value, but it needs to go through the new.html AND form.html. How can I pass through both?

 def new(conn, _params) do
    changeset = Administration.change_admin(%Admin{})

    admin_roles = AdminRolesEnum |>, 0)))

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

Inside of new.html there is syntax like this which I can’t make sense of.

<%= render "form.html", Map.put(assigns, :action, Routes.admin_path(@conn, :create)) %>

This fails:
<%= render "form.html", Map.put(assigns, :action, Routes.admin_path(@conn, :create)), admin_roles: @admin_roles %>

* 1st argument: not an atom

How I do this? Pass admin_roles down to form.html ? Such a basic thing is very complicated in Phoenix.

The last argument to render can be a map or a keyword list. You’re basically passing both a map and then a keyword list.

Try this:

<%= render "form.html", Map.merge(assigns, %{action: Routes.admin_path(@conn, :create)), admin_roles: @admin_roles} %>