If you don't mark a file field as "Multiple values" it becomes a single value field: There is only one file allowed to be uploaded. To make a file field delete its former file once a new one is uploaded the former one has to be marked as "Delete". Unfortunately the file field is always marked as to be deleted even if there is no new file uploaded. The mark will be set internal ($form[$fieldname][$delta]['remove']['#value'] = 1) after submitting the HTML form so there is no way to unmark it from the formular the file field belongs to. This makes the file field to delete its content every time you submit the form. The attached patch will fix this by marking it only if there is a new file uploaded.
| Comment | File | Size | Author |
|---|---|---|---|
| filefield_delete_original_item.patch | 733 bytes | fuerst |
Comments
Comment #1
kevinwalsh commentedThanks Fuerst, this is helpful!
Comment #2
dopry commentedThis should be fixed in HEAD for Drupal 5. I'll work on a backport to 4.7 tomorrow.
http://drupal.org/node/107240