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.
Node Type TT has only one field: field_fc (field collection)
Entity field_collection_item.field_fc has only 1 field: field_ffc (field collection)
Entity field_collection_item.field_ffc has only 1 field: field_text (text field).
Steps to produce the bug:
1. Create a node:
Go to /node/add/tt
Create 3 item for field_fc field.
Save
2. Edit
Edit the node
Remove the first item
Save
The 3rd item also lost.
Attachment is the exported feature.
Comment | File | Size | Author |
---|---|---|---|
#2 | field-collection.1842516.diff | 1.59 KB | thehong |
fcbug.zip | 4.76 KB | thehong |
Comments
Comment #1
kscheirerThanks for the good bug report! I can't even get the ajax "Add" and "Remove" buttons to work :/ My experience was different, although there's definitely something going on here:
Investigating into the ajax problem, I see the calls go out, but the responses are empty! Could be something to do with that
if($messages)
infield_collection_remove_js()
. Though it's not causing this issue, the hook_menu() entry for that ajax callback is wrong, these items should be removed:Comment #2
thehong CreditAttribution: thehong commentedMy patch.
Comment #3
kscheirerTested against 7.x-1.0-beta4+14-dev, bug still exists. Patch fixes it. After the patch I was able to add/remove fields and change orders, everything worked. Thanks thehong!
Comment #4
fagosry, but I don't get what the patch does. Could you please explain what it does and why it is necessary? Ideally, there would be already code comments that help me understand the code.
Comment #5
thehong CreditAttribution: thehong commentedThis line may explain the code:
+ drupal_array_set_nested_value($form_state['field']['#parents'], $address, $_field_state);
Variables $form_state['field']['#parents'] was not managed well, which cause we lost content when delete fc item.
Comment #6
kscheirerI noticed the bugs when you have a field set to unlimited in a nested field collection. You're not able to delete or reorder the fields properly. If you download the feature.zip in #1, you can see the problem right away.
Comment #7
brian_c CreditAttribution: brian_c commentedI was having this issue with beta4 (deleting one image from inside a Field Collection was deleting EVERY image, for a multiple image field).
However this problem appears to be fixed with beta5 (and the latest dev), so I don't think this patch is needed anymore... I can delete (and reorder) stuff just fine now.
Biggest problem with beta5/latest dev is that if you already have the field_collection_item_revision table present, the DB update fails disastrously (I'm talking Error 500 and broken site).
Comment #8
tame4tex CreditAttribution: tame4tex commentedI was not able to reproduce this bug in the latest version of dev (beta6+8). I vote for marking this issue as fixed. Would be nice to get one out of the queue!
Comment #9
thehong CreditAttribution: thehong commented