Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have drupal 7.23 with field-collection version - 7.x-1.0-beta7. Whenever remove button is clicked the row is displayed as it is even though entry is not getting saved.
1.Click on add another item
2. Add values in text field for a field collection.
3. Click on remove button
4. fields keep showing along with values.
5. Add another item, now new collection field shows previously values which are entered in previous fields which are supposed to be removed in above step.
I have also tried Patch given here: https://drupal.org/files/1234574-field-collection-remove-button_0.patch
But this is of no use.
it is not showing any JS error in console.
Please help me to solve this issue.
» Remove button does not remove/clear field item(s)
Version:
7.x-1.0-beta5
» 7.x-1.x-dev
This issue is still valid and it's reproducible in -dev version. When clicking the 'remove' button all fields should be empty including file,image fields should be removed as well. Currently 'remove' only works on child items but does not work on the parent item.
Note that patch in first comment is obsolete since field_collection already has most of that code in place. Perhaps it needs to be re-rolled to test if that actually has a fix.
» Remove button does not remove/clear field correct item(s)
Component:
Code
» User interface
Whenever I hit "remove" the last item is always the one that gets removed!
I am getting the appositive effect, when ever i hit "remove" the first item is always the one that gets removed! What is going on here lulz
EDIT: ok, my issue is actually not related to fc but multiple_fields_remove_button module, but in fc the remove button is still broken in my case where it doesn't clear the last item's content but can remove secondary items.
I think the remove button code in beta8 should be working. What I gather from the comments is that this issue no longer occurs. Please reopen if this is incorrect.
Like i said on Jon Pugh's post, i'm struggling with the same problem.
When i "add another" and delete some fc row item (not the last one), no one disappear.
Then if i save my content form, the last item of my fc has been removed.
At the opposite, when i load my full filled content form and i remove any fc row item, everything works fine.
This problem occurs only when you "add another" and want to remove some row at the same time.
Hi! I have a similar problem. In my situation I have nested field collections. In my case when I have one parent collection all items of it are removing without problem. But when I add another item of first level, then I have problems of deleting items in first collection. I've made some investigations and found. That items are actauly deleting but the form element doesn't replaced. What I've found that the $element['#id'] in function field_collection_remove_js is correct if I have one parent item. In other case in the code $element['#id'] is the same but in the DOM of page the id has "--2" in the end. For example: in the code I have "edit-field-new-product-und-0-field-replacement-variant", in the DOM "edit-field-new-product-und-0-field-replacement-variant--2". So it didn't replaced. But for the second item I have "edit-field-new-product-und-1-field-replacement-variant" in the code and the same id in the DOM and for this element all items are deleting fine. I am in finding solution how to get the correct id. Maybe someone will have the idea how to resolve this too.
Delete button works for me in beta8 but is broken in beta10...has no effect at all. *I am using field collections on a custom multi-step form but still...works fine in beta8.
Comments
Comment #1
Stephen OllmanThere is a patch for this that does remove, but in my experience it only removes the last item. I'm about to create another issue for that.
https://drupal.org/files/1234574-field-collection-remove-button.patch
Comment #2
priyanka12chavan CreditAttribution: priyanka12chavan commentedI have drupal 7.23 with field-collection version - 7.x-1.0-beta7. Whenever remove button is clicked the row is displayed as it is even though entry is not getting saved.
1.Click on add another item
2. Add values in text field for a field collection.
3. Click on remove button
4. fields keep showing along with values.
5. Add another item, now new collection field shows previously values which are entered in previous fields which are supposed to be removed in above step.
I have also tried Patch given here: https://drupal.org/files/1234574-field-collection-remove-button_0.patch
But this is of no use.
it is not showing any JS error in console.
Please help me to solve this issue.
Comment #3
kiliweb CreditAttribution: kiliweb commentedThanks Stephen, the patch resolve my issue.
In my experience, it removes the right item with the patch applied.
Comment #4
likewhoa CreditAttribution: likewhoa commentedThis issue is still valid and it's reproducible in -dev version. When clicking the 'remove' button all fields should be empty including file,image fields should be removed as well. Currently 'remove' only works on child items but does not work on the parent item.
Note that patch in first comment is obsolete since field_collection already has most of that code in place. Perhaps it needs to be re-rolled to test if that actually has a fix.
Comment #5
Jon PughWas this "other issue" ever created or resolved?
Whenever I hit "remove" the last item is always the one that gets removed!
Comment #6
likewhoa CreditAttribution: likewhoa commentedI am getting the appositive effect, when ever i hit "remove" the first item is always the one that gets removed! What is going on here lulz
EDIT: ok, my issue is actually not related to fc but multiple_fields_remove_button module, but in fc the remove button is still broken in my case where it doesn't clear the last item's content but can remove secondary items.
Comment #7
Jon PughDisregard my post.
I discovered the cause of my problem and posted it here: #2351357: Moving the position of a field collection within a form causes "Remove" button to only act on the last item.
Comment #8
jmuzz CreditAttribution: jmuzz commentedI think the remove button code in beta8 should be working. What I gather from the comments is that this issue no longer occurs. Please reopen if this is incorrect.
Comment #9
NVaissaud CreditAttribution: NVaissaud commentedI don't think this issue can be closed yet.
Like i said on Jon Pugh's post, i'm struggling with the same problem.
When i "add another" and delete some fc row item (not the last one), no one disappear.
Then if i save my content form, the last item of my fc has been removed.
At the opposite, when i load my full filled content form and i remove any fc row item, everything works fine.
This problem occurs only when you "add another" and want to remove some row at the same time.
Comment #10
khiminrm CreditAttribution: khiminrm commentedHi! I have a similar problem. In my situation I have nested field collections. In my case when I have one parent collection all items of it are removing without problem. But when I add another item of first level, then I have problems of deleting items in first collection. I've made some investigations and found. That items are actauly deleting but the form element doesn't replaced. What I've found that the $element['#id'] in function field_collection_remove_js is correct if I have one parent item. In other case in the code $element['#id'] is the same but in the DOM of page the id has "--2" in the end. For example: in the code I have "edit-field-new-product-und-0-field-replacement-variant", in the DOM "edit-field-new-product-und-0-field-replacement-variant--2". So it didn't replaced. But for the second item I have "edit-field-new-product-und-1-field-replacement-variant" in the code and the same id in the DOM and for this element all items are deleting fine. I am in finding solution how to get the correct id. Maybe someone will have the idea how to resolve this too.
Comment #11
R.Muilwijk CreditAttribution: R.Muilwijk commentedStill have problems deleting with beta8.
Comment #12
jmuzz CreditAttribution: jmuzz commented@khiminrm That's not the behavior described in the issue summary. Lets try to keep tickets focused on one issue. I have created a separate one for yours: #2404153: Remove button breaks in nested field collections
If anybody is still experiencing the problem explained in the issue summary please provide steps that can be taken to reproduce.
Comment #13
jmuzz CreditAttribution: jmuzz commentedComment #14
R.Muilwijk CreditAttribution: R.Muilwijk commentedTo reproduce move the field collection inside a field group programatically or use the multistep module
Comment #15
mekal CreditAttribution: mekal commentedDelete button works for me in beta8 but is broken in beta10...has no effect at all. *I am using field collections on a custom multi-step form but still...works fine in beta8.
Comment #16
jmuzz CreditAttribution: jmuzz commentedChanging priority as all indications are it is only affecting users using custom code or other contributed modules.
Anybody know if this is happening at all in the latest dev version, or how to reproduce on it?
I'm thinking it might have been fixed by the commit for #2456307: Item Remove Button confuses #parents and #array_parents
Comment #17
jmuzz CreditAttribution: jmuzz commentedComment #18
Elijah LynnComment #19
Elijah LynnComment #20
Elijah LynnComment #21
Elijah Lynn