Problem/Motivation
With a multi-valued field collection field on any form where #parents and #array_parents differ, the remove button appears to always remove the last item no matter which remove button is pressed.
To test this, create a form using the flexiform module and include a field collection field with multiple items. The remove button will appear to remove the wrong item.
Proposed resolution
#parents and #array_parents are different for a good reason! They let you put the submitted values in one place in the $form_state['values'] (#parents) and have the form element in a different location in the $form array (#array_parents). A module as popular as field collection should respect this difference!
Update the field_collection_remove_submit() function to respect the difference between #parents and #array_parents
Remaining tasks
- Review Patch
User interface changes
None
API changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2456307-1.patch | 2.77 KB | rlmumford |
Comments
Comment #1
rlmumfordHere's a patch.
I've added a variable called $values_address which is analogous to $address, but based on #parents instead of #array_parents. Whenever accessing or storing information in $form_state['values'] and $form_state['input'] I switch to using the $values_address and its derivatives.
Comment #2
rlmumfordBump, Flexiform Module still requires this.
Comment #5
jmuzz commentedThanks!
Comment #6
msmorais commentedI'm using version dev and even after applying the patch the problem continues
Comment #8
elijah lynn