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 |> Enum.map(&to_string(elem(&1, 0)))
render(conn, "new.html", changeset: changeset, admin_roles: admin_roles)
end
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.