How to handle forms that create multiple arguments

Here’s a form:

It will create N Animals, two ServiceGaps, and N * 2 join-table entries between them. (This is not an ideal approach, but I wanted to learn things about Ecto.Multi, etc.)

Are there examples or writeups of how to handle such situations? I’m finding it awkward, especially when it comes to error handling.

Well I did something similar, but in my case I didn’t use Ecto.Multi.
I just process the field with multiple values by extracting the list of items to insert (animal names in your case), then call recursively the right context create method with the right attrs. Like that, on the first insert failing, the form will be displayed back with the appropriate animal name in your case. All animal names before that name (if there are) would have been inserted. And all animal after that name, must be filled again.

Maybe someone here will clarify the right way to go ?