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 :id
s to exist: Phoenix LiveView form with nested embeds and add/delete buttons · GitHub