i saw many topics in the forum discuss about this and a github ticket but no clear answer out there (i guess the issue was not presented in a clear way).
instead of making new thread i will ask your same question in another way if you allow me.
we have a DB/Model that contains file field and another field let us call it: title.
we need to update the title in a particular record that contains value in that file field (let say [color="#0000FF"]filename.jpg[/color] <string>).
this is our current record will be:
title: my old title
[color="#8B0000"]result after update is:[/color]
title will be updated successfully BUT the file field value ([color="#0000FF"]filename.jpg[/color]) will be deleted from DB even if we don’t want to delete it.
our record after update is:
title: updated title
1- how to update a (record/db row) that have a file field without (re-uploading) the file again since yii delete default value. <it can be done from old Model record before $model->save()>.
2- ok. here is the main concern: in update if we did not upload a file, we always get an empty value from submitted form.so the question is:
from this submitted empty file filed how we can distinguish if the user want to "keep" the existing file_name in db OR he wants to "delete" this file from DB?
apart from that, updating field in DB should be straight forward without messing with any other data in that record! developers should not figure out a workaround to keep other fields data (save) from deletion.