Nested form not rendering

I have a very simple form. A User can register and also specify the name of their Organisation. For some reason, the nested form (via inputs_for) which captures the Organisation name is not appearing on the page. Any ideas?

<%= form_for @changeset, Routes.user_registration_path(@conn, :create), fn f -> %>
...

  <%= label f, :first_name%>
  <%= text_input f, :first_name, required: true %>
  <%= error_tag f, :first_name %>

...

  <%= inputs_for f, :organisations, fn o -> %>
    <%= label o, :name%>
    <%= text_input o, :name %>
  <% end %>

...

  <div>
    <%= submit "Register" %>
  </div>
<% end %>

inputs_for will render nothing if organisations is [].

2 Likes

That was it. :slight_smile:

Thank you!

If it helps anyone, this is how I populated the organisations property with an empty list in with an empty Organisation struct. I wrote this in a context function before calling a changeset function.

user = %User{user | organisations: [%Organisation{}]}