Weird problem that I don’t really understand here:
I’m working on a fairly complex form that’s manipulating a lot of associations all at once.
<.form ...>
...
<%= for f <- inputs_for(f, :entries) do %> <!-- Has many -->
...
<%= for f <- inputs_for(f, :quiz) do %> <!-- Has one -->
...
<%= for f <- inputs_for(f, :questions) do %> <!-- Has many -->
<p>This content doesn't render</p>
<% end %>
<% end %>
<% end %>
</.form>
Nothing inside the third for
renders for some reason. I’ve put <% IO.inspect("rendering") %>
inside the for loop and confirmed it is looping.
I’ve also confirmed that the contents of the loop are not being sent over the websocket. The diff message doesn’t include anything where the loop should be generating content.
I’ve also wrapped an IO.inspect
around the whole loop to see what’s being generated:
<%= IO.inspect(for f <- inputs_for(f, :questions) do %>
...
<% end) %>
I can see the html markup list stuff that the loop should be returning.
What’s weird is that when I add the IO.inspect
, the markup does get sent to the browser and rendered correctly!
All I can think is that HEEx/LiveView has some limit to the level of nested looping it can handle, and wrapping it up in a function call bypass some change tracking code or something like that? Three loops seems like a really low limit though.