Skip hidden fields on Phoenix inputs_for
I just found out that Phoenix Component inputs_for accepts a skip_hidden
attr which was very useful today. We have a has_many
relationship that we are using <.inputs_for>
to decompose the nested fields and as it was generating some hidden fields the style was breaking.
We are actually using a Tailwind divide on the parent tag and those hidden fields were adding extra separation borders. A way to solve that was calling <.inputs_for
twice as this:
<div>
<.inputs_for field={@form[:posts]} />
<div class="divide-y">
<.inputs_for :let={form} field={@form[:posts]} skip_hidden>
<.input type="text" field={form[:title]} label="Title" />
</.inputs_for>
</div>
</div>
Tweet