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.

Comments

quicksketch’s picture

Status: Active » Needs work

Sure, 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?

effulgentsia’s picture

Status: Needs work » Needs review
StatusFileSize
new574 bytes
effulgentsia’s picture

Here's another patch which does the same thing, but with what I think is less funny code, and a comment explaining it.

effulgentsia’s picture

Title: Request change to 1 line of code to make filefield compatible with flexifield » Name construction of remove button causes incompatibility with flexifield

Changed issue title to be more helpful.

quicksketch’s picture

Status: Needs review » Fixed

Thanks, I like the new approach much better. Committed!

nicholas.alipaz’s picture

I 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.

nicholas.alipaz’s picture

Status: Fixed » Needs review

BTW, I tried this with both cck 6.x-2.x-dev and cck 6.x-2.2, same issue in all situations.

nicholas.alipaz’s picture

Any comments on this issue? am I the only one seeing it?

effulgentsia’s picture

Status: Needs review » Fixed

@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.

quicksketch’s picture

Thanks 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.