X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Finline_entity_form%2Fsrc%2FTranslationHelper.php;h=6ff8670eb065dffa8b7856c1a238a311d6a9f844;hp=6c71e5f054b261dd377ffb75a964d81549cac7d1;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/inline_entity_form/src/TranslationHelper.php b/web/modules/contrib/inline_entity_form/src/TranslationHelper.php index 6c71e5f05..6ff8670eb 100644 --- a/web/modules/contrib/inline_entity_form/src/TranslationHelper.php +++ b/web/modules/contrib/inline_entity_form/src/TranslationHelper.php @@ -21,7 +21,7 @@ class TranslationHelper { * @return \Drupal\Core\Entity\ContentEntityInterface * The prepared entity. * - * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes(). + * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes() */ public static function prepareEntity(ContentEntityInterface $entity, FormStateInterface $form_state) { $form_langcode = $form_state->get('langcode'); @@ -34,6 +34,9 @@ class TranslationHelper { // Create a translation from the source language values. $source = $form_state->get(['content_translation', 'source']); $source_langcode = $source ? $source->getId() : $entity_langcode; + if (!$entity->hasTranslation($source_langcode)) { + $entity->addTranslation($source_langcode, $entity->toArray()); + } $source_translation = $entity->getTranslation($source_langcode); $entity->addTranslation($form_langcode, $source_translation->toArray()); $translation = $entity->getTranslation($form_langcode); @@ -97,7 +100,7 @@ class TranslationHelper { * @return bool * TRUE if translating is in progress, FALSE otherwise. * - * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes(). + * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes() */ public static function isTranslating(FormStateInterface $form_state) { $form_langcode = $form_state->get('langcode');