Inputs_for/4 collection indices

With sub_form.index you get exactly that. inputs_for afaik even uses Enum.with_index internally, so no need to duplicate efforts.

The index can be really useful especially if one needs to tack on “add new rows” / “delete existing rows” functionality without needing :ids to exist: Phoenix LiveView form with nested embeds and add/delete buttons · GitHub

4 Likes