1) Create a content type with a repeating field collection
2) Enable translations
3) Add content in the field collection in a node
4) Translate the node

Expected: The new node has the same field collections data as the parent node

Actual: No field collection data is copied to the new node

Comments

I've run into an issue that could be related. I built a site, and field collection functionality was working perfectly. I enable i18n modules and started working on a translation, and the field collection (subform) widget no longer saves any data. No new field collection entities are created (in either language)... nothing is saved to the database. This is critical for a project due very soon, so I'll try and come up with a solution, though I may have to go a different route if I can't figure it out quick enough.

Further investigation: Only the widget included in the patch in http://drupal.org/node/977890#comment-4237396 has the i18n issue for me. If I create a field collection the normal way it saves and shows up in both languages.

Having the similar issue as OP.

1) Add new node
2) Add couple of field collections to said node
3) Translate node into another language
4) Open translated node and it has no field collections

I realise we can turn on 'language sync' on the collection field in the content type but then it does not become translatable.

What is the best way of making a field collection translatable? I'm guessing this is mainly a widget problem? If the widget appeared inline with the node entry fields then when you translated a node, you could also do the collection at the same time.

Any solution for this?

I tested the patch in http://drupal.org/node/977890#comment-4564324 with content translation - the result is here.

I think that's normal, as this module is at its early beginning, i18n is not aware of it. But I tried to translate a page with field collections with content translation, for curiosity's sake.

Just for your information, the result is, on a content translation edit page, with an embedded widget, if you clic the add button you receive the following:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /fr/system/ajax
StatusText: Service unavailable (with message)
ReponseText: Recoverable fatal error : Argument 1 passed to field_collection_item_is_empty() must be an instance of FieldCollectionItemEntity, null given, called in (...)/sites/all/modules/field_collection/field_collection.module on line 887 and defined in field_collection_item_is_empty() (line 552 in (...)/sites/all/modules/field_collection/field_collection.module).

That confirms that field collection translation doesn't exist in Drupal 7 yet.

If you save the translation:
Notice : Undefined index: field in field_widget_field() (line 521 in (...)/modules/field/field.form.inc).
Notice : Undefined index: instance in field_widget_instance() (line 546 in (...)/modules/field/field.form.inc).
Notice : Undefined index: field in field_widget_field() (line 521 in (...)/modules/field/field.form.inc).
Notice : Undefined index: instance in field_widget_instance() (line 546 in (...)/modules/field/field.form.inc).
Notice : Undefined index: field in field_widget_field() (line 521 in (...)/modules/field/field.form.inc).
Notice : Undefined index: instance in field_widget_instance() (line 546 in (...)/modules/field/field.form.inc).
Notice : Undefined index: entity in field_collection_field_widget_embed_validate() (line 881 in (...)/sites/all/modules/field_collection/field_collection.module).
Notice : Trying to get property of non-object in entity_extract_ids() (line 7368 in (...)/includes/common.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Notice : Trying to get property of non-object in entity_extract_ids() (line 7368 in (...)/includes/common.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Notice : Trying to get property of non-object in entity_extract_ids() (line 7368 in (...)/includes/common.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Notice : Undefined index: field_name in _field_invoke() (line 188 in (...)/modules/field/field.attach.inc).
Recoverable fatal error : Argument 1 passed to field_collection_item_is_empty() must be an instance of FieldCollectionItemEntity, null given, called in (...)/sites/all/modules/field_collection/field_collection.module on line 887 and defined in field_collection_item_is_empty() (line 552 in (...)/sites/all/modules/field_collection/field_collection.module).

So nothing to worry about until this module is released and taken into account by i18n's team. Yet I don't know if it's possible to simplify i18n's team future work during the actual module development.

I've got a similar error creating a node (which has some field collections in it) with i18n and content translation enabled :-(

    Notice: Undefined index: entity in field_collection_field_widget_embed_validate() (line 885 of /var/www/sites/all/modules/field_collection/field_collection.module).
    Notice: Trying to get property of non-object in entity_extract_ids() (line 7368 of /var/www/includes/common.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Notice: Trying to get property of non-object in entity_extract_ids() (line 7368 of /var/www/includes/common.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Notice: Trying to get property of non-object in entity_extract_ids() (line 7368 of /var/www/includes/common.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Notice: Undefined index: field_name in _field_invoke() (line 188 of /var/www/modules/field/field.attach.inc).
    Recoverable fatal error: Argument 1 passed to field_collection_item_is_empty() must be an instance of FieldCollectionItemEntity, null given, called in /var/www/sites/all/modules/field_collection/field_collection.module on line 891 and defined in field_collection_item_is_empty() (line 552 of /var/www/sites/all/modules/field_collection/field_collection.module).

I'm using the latest -dev of i18n and field_collection and entity API 7.x-1.0-beta8.

Any news for that issue? (mainly with Field Translation enabled)

It looks that field_collections doesn't support i18n: http://drupal.org/node/1186878#comment-4625730
:-(

I tried to use field collection in profile fields. My site is multilingual. How can I 'turn off' the profile translation?

I investigated the code, and found a mislogic. My php error disappeared and it looks good, but the warnings not.

field_collection.module at line 892

<?php
 
if (!field_collection_item_is_empty($field_collection_item) && !empty($element['#field_collection_required_elements'])) {
?>

should be

<?php
 
if (!empty($element['#field_collection_required_elements']) && !field_collection_item_is_empty($field_collection_item)) {
?>

The params are swapped.

Here the problem appears as soon the 'Field translation' module is activated. Even on content types with translation turned off. As soon a record is saved the following messages are shown and nothing is stored.

Notice: Undefined index: field in field_widget_field() (Zeile 521 von /www/modules/field/field.form.inc).
Notice: Undefined index: instance in field_widget_instance() (Zeile 546 von /www/modules/field/field.form.inc).
Notice: Undefined index: field in field_widget_field() (Zeile 521 von /www/modules/field/field.form.inc).
Notice: Undefined index: instance in field_widget_instance() (Zeile 546 von /www/modules/field/field.form.inc).
Notice: Undefined index: entity in field_collection_field_widget_embed_validate() (Zeile 888 von /www/sites/all/modules/field_collection/field_collection.module).
Notice: Trying to get property of non-object in entity_extract_ids() (Zeile 7368 von /www/includes/common.inc).
Notice: Undefined index: field_name in _field_invoke() (Zeile 188 von /www/modules/field/field.attach.inc).
Notice: Trying to get property of non-object in entity_extract_ids() (Zeile 7368 von /www/includes/common.inc).
Notice: Undefined index: field_name in _field_invoke() (Zeile 188 von /www/modules/field/field.attach.inc).
Notice: Trying to get property of non-object in entity_extract_ids() (Zeile 7368 von /www/includes/common.inc).
Notice: Undefined index: field_name in _field_invoke() (Zeile 188 von /www/modules/field/field.attach.inc).
Recoverable fatal error: Argument 1 passed to field_collection_item_is_empty() must be an instance of FieldCollectionItemEntity, null given, called in /www/sites/all/modules/field_collection/field_collection.module on line 896 and defined in field_collection_item_is_empty() (Zeile 552 von /www/sites/all/modules/field_collection/field_collection.module).

If 'Field translation' is turned off ('Internationalization' and 'Multilingual content' still on) it works fine.

I did some debugging and found a bug in i18n_field. I reported it with a patch to the Internationalization project: #1197866: $form_state does not get passed correctly in i18n_field_field_widget_form().

This fixes my problem. I'm not sure if all other issues in this thread are also fixed with this.

Related to this issue: I've created a feature request for translation support #1316162: Support content translation and host entity cloning

I'm not certain whether the feature request encompasses this particular issue fully so I'll leave as-is for now. Feel free to mark this issue as duplicate or close.

Number for also solved the problem for me, thanks for the work!

grts

frederic

As a quick patch, I have done the following changes to my field_collection.module as follows because these lines used to trigger warnings which were breaking the saving process for nodes using field collections. Afaik this patch doesn't have side-effects on my nodes creations.

function field_collection_field_is_empty($item, $field) {
  if (!empty($item['value'])) {
    return FALSE;
  }
  elseif (isset($item['entity'])) {
    if (!empty($item['entity']->item_id)) {
      return field_collection_item_is_empty($item['entity']);
    }
  }
  return TRUE;
}

then on line 1253 (this also used to trigger errors)

  if (!empty($field_collection_item->item_id)) {
    // Attach field API validation of the embedded form.
    field_attach_form_validate('field_collection_item', $field_collection_item, $element, $form_state);
    // Now validate required elements if the entity is not empty.
    if (!field_collection_item_is_empty($field_collection_item) && !empty($element['#field_collection_required_elements'])) {
      // ... here goes all this condition's content
    }
  }

I'm not submitting as a patch because I have no idea what these two changes might involve, but it seemed to me that was basic values validation and it shouldn't even have popped up as a warning in the first place.

Please feel free to comment and maybe (in the end) apply as a patch. I need a more insightful opinion to know if this is alright or if I just flung open the doors to hell.

I think this bug is only valid when node (content) translation is used - not with field (entity) translation. If so, it should clearly be stated in the issue's summary.

It happens the same

When I put translation is updated in both cases (Spanish/English)

Someone could solve this problem?

Sorry for late reply, but for anyone else seeing this issue see: #1316162: Support content translation and host entity cloning