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.
hey guys,
I'm implementing a custom submit handler (for a n entityform) and running into wall with handling field collection items. I got everything in a wrapper (entity_metadata_wrapper), and everything else insert ok. Went through a quite a few posts online with not much success.
Entiyform has field collection item field_movie
Field collection item field_movie has
- year
- name
- studio
Thanks.
Comments
Comment #2
j-phat CreditAttribution: j-phat commentedComment #3
hondaman900 CreditAttribution: hondaman900 commentedDid you find a solution and, if so, can you share code? I too am having difficulty saving new data to an existing FC. I use a FC in an entityform, and list the multiple entityforms and FC contents as rows in my own module custom form. Only the last FC in in the group (wrapper) is saved and the prior FCs are ignored. Looking for ages and can't find any takers to weigh in on what I'm doing wrong.
Comment #4
j-phat CreditAttribution: j-phat commentedi had this happen before, only to realize i hadn't changed the field names. if that's not the case, try dumping the field values to make sure they have the correct values just before submit. hope that helps.
Comment #5
hondaman900 CreditAttribution: hondaman900 as a volunteer commentedThanks for the reply j-phat.
Not sure what you mean by "change the field names". In my foreach loop I cycle through the multiple field collection fields in an entityform (because the entityform allows for multiple fc's) and the field I'm changing is the same name in each fc. I change the names of the form fields to match the correct form field with the correct FC field. I do a
dsm()
dump to check if myset()
statement is working and I see all the correct values set, but the lastwrapper->save()
statement only saves the last fc.Here's the code:
Comment #6
j-phat CreditAttribution: j-phat commentedHondaman, try saving the fieldset inside the foreach loop.
Comment #7
hondaman900 CreditAttribution: hondaman900 as a volunteer commentedWow! Of course, that works and explains why I was only getting the last one saved - I couldn't see it. It works fine now.
Thank you SO much. I've lost over a week trolling forums ad posts and posting this everywhere trying to figure this perplexing issue out. You saved my life on this one!