Phoenix.HTML.Form.inputs_for form collections without a changeset

I’m trying to build a form using the connection data. I want to make a collection of inputs.

In this way I can make a single nested form:

<%= form_for @conn, page_path(@conn, :index), [as: :user], fn f -> %>
  <%= text_input f, :name %>

  <%= inputs_for f, :address, fn ff -> %>
    <%= text_input ff, :street %>
    <%= text_input ff, :city %>
  <% end %>
<% end %>

But what about collections?

Just specify default values:

<%= inputs_for f, :address, [default: [%{street: nil, city: nil}, %{street: nil, city: nil]], fn ff -> %>
    <%= text_input ff, :street %>
    <%= text_input ff, :city %>
  <% end %>
4 Likes

Thanks!