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.
I was trying to replicate a node which had a paragraphs field that could be translated. Every time I replicated the node, the copy node would have the paragraphs items but in ['und'] rather than the original language(s) that were set.
I looked into the code and found that we are not passing the language into setHostEntity()
. After I passed the language in it was able to save the new copy of the paragraphs items to their correct language(s) on the field.
Comment | File | Size | Author |
---|---|---|---|
#7 | replicate_paragraphs.module 2022-05-27.png | 86.2 KB | mozh92 |
#2 | replicate_paragraphs-2653604-2.patch | 636 bytes | joekers |
Comments
Comment #2
joekersPatch attached.
Comment #3
rossb89 CreditAttribution: rossb89 at ComputerMinds commentedBrilliant, just ran into this issue and was about to go looking for where to patch.
Thanks!
Comment #5
seanBThnx!
Comment #7
mozh92 CreditAttribution: mozh92 commentedPatch doesn't work after default language.
We have 8 languages and clone work only for 'de' and 'en'.
First language in $entity->$field_name we have 'de' and it works, after that we have default language 'en' and also works, but after we get next language and we have $old_items empty.
Fix for this problem: