Multiple Models Manipulated By User

Hello, what is the best way to work with multiple models in forms? I know about this tutorial, but I need a different approach: https://github.com/yiisoft/yii2/blob/master/docs/guide/input-forms.md#handling-multiple-models-with-a-single-form

I don’t have the same models every time, like in the example with the settings. I have attachments which the user is able to manipulate: he should be able to add or remove an attachment (handled with JS).

Example: there are 2 attachments saved in the database. When the user loads the page the 2 attachments will be listed. Now he changes the title of attachment #1, he deletes #2 and adds a new one. Then #1 should be updated in the database, #2 should be removed and a new one should be added to the database.

I had this problem many times! Does nobody else has such problems?!