I have installed latest version of i18n,dev version of Field Collection and dev version of Entity Translation. When I tried to translate a page which contains field collection, I got this error message

Fatal error: __clone method called on non-object in sites\all\modules\contrib\field_collection\field_collection.module on line 1669
I did dpm before that line and found that $field_state doesn't have index called 'entity' that's why its was giving problem.
Is there a way to ignore this if it doesn't have this index ?

dpm($field_state); when I did this I saw this attachment.

$field_collection_item = clone $field_state['entity'][0];

CommentFileSizeAuthor
fc-clone-error.JPG50.75 KBghalenir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ghalenir’s picture

I have nested field collection so I have parent field collection called field_homepage_lead_slider and it has another field collection called field_fc_video that may be causing a problem.

ghalenir’s picture

I don't know how to clone field collection item but I added following code and its working now. I don't know if I added right code or not.

if(isset($field_state['entity'][0]))
$field_collection_item = clone $field_state['entity'][0];
else
{
* if it doesn't have entity object then we get the home page slider Field collection ID and clone it

$homepage_slider_id = db_select("field_data_field_homepage_lead_slider", "homepage_slider")
->fields("homepage_slider", array("field_homepage_lead_slider_value"))
->condition("language", "en")
->condition("delta",$field_parents[2])
->execute()
->fetchField();

$fcitem_item = entity_load('field_collection_item', array($homepage_slider_id));
$field_collection_item = clone $fcitem_item[$homepage_slider_id];
}

jmuzz’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

Field collection does not yet support entity translation. You can try the patch in the issue for it.

#1344672: Field Collection: Field translation (entity_translation) support.