Fixing FileField, part 4. (Actually, this has little to do with filefield specifically, but I spotted and fixed this while working on it.)

content_multiple_value_form() currently has '#field_name' and '#type_name' disabled, which in turn caused the non-JS submit function, content_add_more_submit(), to employ a workaround of adding a new item to *all* fields when the "Add another item" button is pressed.

I suppose someone didn't know the trick to assign a '#name' to a button so that Forms API can actually tell it apart from other buttons with the same label. Knowing how to make this work, this patch is trivial and causes non-JS "add more" actions to only add a new item to the field where the button was actually pressed.

Comments

yched’s picture

could you roll this one,
http://drupal.org/node/273481 and
http://drupal.org/node/273476 into a single patch ?

Thx.

jpetso’s picture

StatusFileSize
new4.37 KB

Here you are - combined patch of the 3F issues #1, #2 and #4. (Good thing I had them committed to my Git repository in exactly that order, made it easy to roll a diff :D )

yched’s picture

Thanks for this.
Fixing 'add more' for non-JS has been on my todo pretty much since it's been committed, but quite frankly, not on on top. And it got broken completely when the content.node_form.inc split was introduced, without anyone actually noticing it.

Problem with the above patch is that it breaks the long-standing 'provide one empty widget in addition to existing values' behavior when editing an existing node. The 'add more' button will provide one if needed, of course, but you need to click and wait, and I feel people will live this as a regression, so I'd really like to keep this convenience.
I'll try to come up with something, and commit the current patch if I can't soon enough.

jpetso’s picture

Assigned: Unassigned » jpetso
Status: Needs review » Needs work

Claiming this issue. I got an improved patch running that should satisfy both my needs and the issue that you mention, I just need to clean up the code a bit more (changed more than was necessary).

jpetso’s picture

Status: Needs work » Needs review
StatusFileSize
new4.63 KB

Here you are! If you liked the previous patch, you'll love this one :)

yched’s picture

Beautiful. Committed. Thanks !

yched’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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