Phoenix LiveView diff-tracking and forms in child templates (inputs_for/3)

In the documentation it is stated that diff checking works for sub-templates as long as all assigns are forwarded:

<%= f = form_for @changeset, "#",  phx_change: :validate, phx_submit: :save %>
<%= render "child.html", assigns %>

inside the child @changeset is now available but not f. Thus this will fail:

<%= for fs <- inputs_for(@f, :comments) do %>
<% end %>

Of course instead of providing assigns, i could just provide f manually. But then the child template would no longer be diff-tracked.

Also recreating f inside the child template is not possible because then i would have a form inside another form which invalidates html.

Is there a way to do inputs_for/3 in the child template in combination with phoenix live view’s diff tracking?

Sorry to ping again. This is still a relevant issue and any piece of wisdom would be appriciated.


What if you add f to assigns map and pass that to the child template, would that work?

<%= render "child.html", Map.put(assigns, :f, f) %>

Much appreciated, thanks!

That would work but then I would have the situation again where each form element that uses f would rerender, nullifying the performance gain of live-tracking.