I switched filefield from custom multiple-value handling to CCK's built-in one, which should be a good thing for CCK because the multiple-value handler has some grave bugs and I'm now trying to fix them. In order to get filefield to work without switching back to my old custom table, say hello to a series of at least two or three patches...
Fixing FileField (aka 3F)
Ok, that should be enough marketing speak for now, please have a look at the attached patch. The problem for me was that when hitting the node's Preview button or filefield's Upload or Delete ones, CCK adds lots of additional item widgets. That is, at least two more items even if I didn't ask for a single one.
That issue has two causes:
- The Preview, Upload and Delete buttons don't save the node, and thus don't invoke hook_nodeapi($op = 'presave'). As a consequence, the item for the $field_name .'_add_more' button is still in the $items array when content_form() is called, which causes count($items) to be one more than expected. (The other consequence is that content_set_empty() is not called, but that's ok because modules might actually want to store additional information in the item until the node is saved. Like, say, files that need to be deleted on saving the node.)
- The result of count($items) is always one more than the current maximum delta, which means every time that one of the above-mentioned buttons is pressed, the multiple-value form adds an item. I don't think that this is the desired behaviour, as new items should only be added when "Add more items" is clicked.
The patch fixes both of these problems. Might open a can of worms somewhere else, but it definitely goes into the right direction. Please review and commit if it's ok.
| Comment | File | Size | Author |
|---|---|---|---|
| cck-multiple-value-fixmax.diff | 1.31 KB | jpetso |
Comments
Comment #1
jpetso commentedProvide a more specific component for this issue.
Comment #2
jpetso commentedRolled into a combined patch with 3F issues #2 and #4, see http://drupal.org/node/274038#comment-893832
Comment #3
yched commented