diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 7c72b84..68c24c3 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -297,7 +297,7 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s $op = $form_object->getOperation(); // Let the content translation handler alter the content entity edit form. - if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && ($op == 'edit' || $op == 'default')) { + if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && ($op == 'edit' || $op == 'add' || $op=='default')) { $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); $controller->entityFormAlter($form, $form_state, $entity); diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php index c97f185..05d42ba 100644 --- a/core/modules/content_translation/src/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php @@ -338,7 +338,10 @@ public function add(LanguageInterface $source, LanguageInterface $target, RouteM // $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; // See https://www.drupal.org/node/2006348. $operation = 'default'; - + // Use the add form handler, if available, otherwise default. + if ($entity->getEntityType()->getFormClass('add')) { + $operation = 'add'; + } $form_state_additions = []; $form_state_additions['langcode'] = $target->getId(); $form_state_additions['content_translation']['source'] = $source; @@ -369,7 +372,10 @@ public function edit(LanguageInterface $language, RouteMatchInterface $route_mat // $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; // See https://www.drupal.org/node/2006348. $operation = 'default'; - + // Use the edit form handler, if available, otherwise default. + if ($entity->getEntityType()->getFormClass('edit')) { + $operation = 'edit'; + } $form_state_additions = []; $form_state_additions['langcode'] = $language->getId(); $form_state_additions['content_translation']['translation_form'] = TRUE;