In filefield_widget_process(), there's the following code:
$element['filefield_remove'] = array(
'#name' => $element['#field_name'] .'_'. $element['#delta'] .'_filefield_remove',
...
This assumes that the combination of field_name/delta uniquely identifies the remove button. While this is normally true within CCK, it is not true when using the flexifield module, resulting in this issue: #446012: Still problem on Imagefield, removing image, remove all the images..
Would you be willing to change the code to:
$element['filefield_remove'] = array(
'#name' => str_replace(array('[', ']'), array('_', ''), $element['#name']) .'_filefield_remove',
...
This results in the same value for #name when not using flexifield, but a more targeted name when using flexifield.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | filefield-flexifield-integration-447572-1.patch | 828 bytes | effulgentsia |
| #2 | filefield-flexifield-integration-447572-0.patch | 574 bytes | effulgentsia |
Comments
Comment #1
quicksketchSure, I don't know any reason why we couldn't change it, especially since it has no effect on FileField's normal output. Though the code does look a little funny, I can see how it works. Could you roll a patch?
Comment #2
effulgentsia commentedComment #3
effulgentsia commentedHere's another patch which does the same thing, but with what I think is less funny code, and a comment explaining it.
Comment #4
effulgentsia commentedChanged issue title to be more helpful.
Comment #5
quicksketchThanks, I like the new approach much better. Committed!
Comment #6
nicholas.alipaz commentedI am still having issues with this in Filefield 6.x-3.x-dev (I checked and it does seem to have this patch applied) and flexifield 6.x-1.0-alpha4 or flexifield 6.x-1.0-alpha3, I have tried both.
On uploading an item, the section where the file would show just goes blank. This is an issue both with filefield and imagefield using filefield.
Comment #7
nicholas.alipaz commentedBTW, I tried this with both cck 6.x-2.x-dev and cck 6.x-2.2, same issue in all situations.
Comment #8
nicholas.alipaz commentedAny comments on this issue? am I the only one seeing it?
Comment #9
effulgentsia commented@nicholas: I'm not seeing the issue you're describing, but I'll dig more into it. Do you have a test site with an account I can log into to look? If so, please send me a personal message with that info.
At any rate, resolving this issue (once I can see it) should be a separate issue for flexifield rather than here. Filefield is a very popular module with a busy issue queue. I appreciate quicksketch's willingness to commit my patch to filefield, but I'd like to minimize putting things on his radar that can be solved within flexifield instead.
Comment #10
quicksketchThanks effulgentsia, much appreciated. Let me know if FileField needs any further changes. FYI a new release of FileField (3.1) should be out relatively soon, allowing Flexifield to use the latest stable version instead of the development version.