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.

CommentFileSizeAuthor
#2 field-collection.1842516.diff1.59 KBthehong
fcbug.zip4.76 KBthehong
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kscheirer’s picture

Status: Active » Needs work
Issue tags: +D7 stable release blocker

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

  • Installed field_collection 7.x-1.0-beta4 and D7.17
  • Installed feature posted in #1
  • Created a new TT node. Because ajax wasn't working, I would enter text and submit the form, then go edit again. Did this 3 times to get 3 elements into the field collection.
  • Saved node, clicked edit, clicked "Remove" on the first text field. No response from ajax. Click "Remove" a second time! Click save.
  • Node now has first and second fields, third is gone.

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) in field_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:

    'file path' => 'includes',
    'file' => 'form.inc',
thehong’s picture

Status: Needs work » Needs review
FileSize
1.59 KB

My patch.

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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!

fago’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

sry, 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.

thehong’s picture

Status: Postponed (maintainer needs more info) » Active

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

kscheirer’s picture

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

brian_c’s picture

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

tame4tex’s picture

Issue summary: View changes

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

thehong’s picture

Status: Active » Closed (cannot reproduce)