CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

Calling multiple saves of the model on same request raises Exception #82

Open tsdogs opened 4 years ago

tsdogs commented 4 years ago

When you call $model->save() multiple times on the same action/request it raises an exception with file upload failed.

I encounter this because I have a complex form which handles main model and submodels. To save the submodules I need to generate the first model key so I initially save the model in a state where it's incomplete to get the primary key. Then save the submodels, and then change the state of the master model to complete (this triggers an event to notify the user).

On the second save the FileBehaviour raises an exception 'cause it cannot find the temporary file which was handled on the first call.