yii2-attachments icon indicating copy to clipboard operation
yii2-attachments copied to clipboard

Calling multiple saves of the model on same request raises Exception

Open tsdogs opened this issue 5 years ago • 0 comments

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.

tsdogs avatar Jul 16 '20 11:07 tsdogs