Form API/Node Revisions: List and description values aren't saved for uploaded files
| Project: | Drupal |
| Component: | upload.module |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Changing the list attribute or description of an uploaded file doesn't work. This is most likely related to the new forms API or node revision changes (or both). I'll attach a patch that fixes the list attribute problem, but the fix for description is more difficult.
In _upload_form(), description is in $form['current']['description'] which has the #tree attribute set to TRUE. The value of description is set within a foreach loop. The list and delete (called remove in the form) checkboxes are set outside that foreach loop. When the form from _upload_form() is returned to upload_from(), it's put into $form['attachments']. When the form is submitted, list and remove are $node['list'] and $node['remove'] whereas description is $node['attachments']['current']['description'].
Part of the bug is that upload_save() expects to access description as $file->description. That should be $node->description. However, with the forms the way they are, that won't work either.

#1
Attaching partial patch that fixes the list attribute problem. This patch also makes preparations to fix the the description problem. I also fixed a logical error, which caused an UPDATE query to fire before it could be used.
#2
Looks like someone fixed the tree problem. List and description now both work. :)
I've rerolled the patch to keep up with head.
#3
Looks good, +1
Robin
#4
Patch looks good and works great here. Dries if you can commit this initial patch, we can start work on the description problem.
Also, this problem is related to (and even possibly a fix for): http://drupal.org/node/31102 ... need to get both of these resolved ASAP!
#5
Patch looks good and works great here. Dries if you can commit this initial patch, we can start work on the description problem.
Also, this problem is related to (and even possibly a fix for): http://drupal.org/node/31102 ... need to get both of these resolved ASAP!
#6
This does fix the description problem.
#7
seems like this is ready to go. any objection from CVS review team?
#8
None here ;-) But yes, I really *need* this patch so we can fix other related problems, these problems are keeping a few of my sites from going live!
#9
Committed to HEAD. Can you update the referenced issue, if that is taken care of now? Thanks.
#10
Will do, we have a tangle of related file issues we are looking into :-)
#11