I have a form with a file upload field in it and I have created a model behaviour file to handle file processing.
I have two functions, beforeSave and afterSave:
In beforeSave I do some stuff and then set the file value in data to null so it can be saved. Else it will try to save an array, and the database expects just a string (the file name)
In afterSave I generate a new file name based on some text fields on the form, and add the lastInsertId infront of it. I also move the file from temp to desired location. This all works fine, but when I try to save the new filename to the Model it just doesnt work.
I have done a lot of test and debugging, and also spent hours searching online. The conclusion is that you can not save in afterSave, it triggers itself and will run beforeSave again.
So my question is, how can I update the newly inserted model? The filename inserted need to have the primary key in its name, and its unknown at time of beforeSave.
grateful for any help! jason