Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
for Field collection translatable Fields (that have "Users may translate this field" option checked (Entity translation) the Field language it's needed instead of LANGUAGE_NONE.
As this field language it's used for the entity field content.
for example
$this->langcode = field_language($entity_type, $entity, $this->field_name);
intead of
$this->langcode = LANGUAGE_NONE;
actually the langcode argument it's really needed here?
Comment | File | Size | Author |
---|---|---|---|
#12 | screenshot_title_alter_not_possible.png | 12.73 KB | marcusx |
#12 | screenshot_title_alter_fixed.png | 11.57 KB | marcusx |
#12 | screenshot_var_dump_fc_trans_exception.png | 20.9 KB | marcusx |
#11 | field_collection-entity_translation-1366220-11.patch | 8.47 KB | marcusx |
#4 | field_collection-1366220-entity_translation.patch | 8.9 KB | longwave |
Comments
Comment #1
floretan CreditAttribution: floretan commentedHere's a patch that uses the language code provided by the Field API hooks instead of hardcoding LANGUAGE_NONE.
The patch also adds a check in the validation handler. This fixes an error on the entity_translation form where the delta of a blank field collection was checked with a non-existent field_state.
Combined with #1367832: Check #parents and #field_parents for source language in new translation form , this patch makes it possible to have translatable field_collection fields with entity_translation!
Comment #2
New_Bee CreditAttribution: New_Bee commentedTranslations are working fine while editing. While adding translation if the parent node has more than one field collection items, only one will be saving for the translation.
Comment #3
duellj CreditAttribution: duellj commentedThe problem with only one field collection being saved for a translation comes from the problem with attaching the $field_state['entity'] during the call to field_collection_field_widget_form(). The translation form is built first by entity_translation with empty fields, then the form fields from the source form (node, taxonomy, etc) are added post processing to fill in the populated default values. At that point, $field_state['entity'] only contains one value, instead of the number of values copied over from the source form, so only one value will be saved.
The best fix would be to rework how entity_translation builds the translation form, but that's a lot of work. Here's a patch that adds a form_alter that adds in the necessary $field_state['entity'] objects for each field collection.
Comment #4
longwave#3 rebased against latest 7.x-1.x.
This works for me except in Views, where even if I select "current language" as the Views field language, I get all languages if I have field collection items pulled into my View.
Comment #5
longwaveActually, it seems the language code doesn't cascade down to the member fields of the collection; the field collection entity itself is given a language code, but the fields that belong to that collection are always of language "und", which is where I think the problem with Views lies.
Comment #6
longwaveNot sure if the Views issue should be solved by Entity translation, in which case #1330332: Entity translation: Views field language filter looks relevant.
Comment #7
chaskype CreditAttribution: chaskype commented#4: field_collection-1366220-entity_translation.patch queued for re-testing.
Comment #9
Dentorat CreditAttribution: Dentorat commentedI manually applied patch at #4 and got the error
Notice: Undefined variable: field_collection_item in field_collection_field_widget_embed_validate() (line 1281 of /sites/default/modules/contrib/field_collection/field_collection.module).
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7539 of /includes/common.inc).
Comment #10
bmx269 CreditAttribution: bmx269 commentedAre there any updates on getting this to work? Thanks
Comment #11
marcusx CreditAttribution: marcusx commentedRefactoring patch to make it apply to the latest dev (and let it hopefully pass the testbot).
Comment #12
marcusx CreditAttribution: marcusx commented@penthehuman: Where do you get these messages?
I can confirm that it is broken if I try to edit a field collection item via its url.
e.g.:
http://my.domain/en/field-collection/field-myfieldname/1/edit
I get errors from entity translation:
Notice: Undefined offset: 0 in entityForm() (line 690 of /.../sites/all/modules/contrib/entity_translation/includes/translation.handler.inc). =>
and
Notice: Trying to get property of non-object in entityForm() (line 690 of /../sites/all/modules/contrib/entity_translation/includes/translation.handler.inc). =>
This comes from the effort of entity translation to append the language to the title.
Here two screenshots to make it clearer whats going on.
Broken Version:
Quickfixed Version: (hacking the value into translation.handler.inc to check if all problems are going away)
But even if the form language if set we cannot save the form. We get
The exception is thrown here:
dump for
$translation
So there is further investigation necessary. Setting this back to "needs work".
UPDATE:
It will work for the embedded widget as I realized meanwhile.
And you must set the field_collection field (on the nodes manage fields page) to translateable itself. I first thought this isn't needed as it will always hold the same field collection item id - but from there comes the language for the fields inside the item.
Comment #13
phreaknerd CreditAttribution: phreaknerd commentedAdded a patch to #1281974: Missing bundle property on entity - related to translations (#52) which seems to fix this issue too.
The fields are now translatable and editable too (by the links in collection view).
One issue still appears: you can't use the "Add"-link in collection view to add a new item. Seemd that the correct relation to the field_collection and parent node is missing.
Another one is that the translated revisions don't get deleted when removing the translation of the parent node.
Comment #14
phreaknerd CreditAttribution: phreaknerd commentedResetting the status: please check the previous patch.
Comment #15
Fidelix CreditAttribution: Fidelix commentedAny news on this?
Comment #16
malberts CreditAttribution: malberts commentedI think this issue can be seen as a sub-issue of integrating Entity Translation.
Therefore marking as a duplicate of #1344672: Field Collection: Field translation (entity_translation) support. where I've recently added a patch for that. Please have a look there so we can try to get that patch fleshed out.
Comment #17
ghalenir CreditAttribution: ghalenir commented#11: field_collection-entity_translation-1366220-11.patch queued for re-testing.
Comment #19
plachThere is a new patch providing full ET integration in #1344672-45: Field Collection: Field translation (entity_translation) support..