diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index c8b2f85..c63b2f8 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -473,7 +473,7 @@ function entity_form_state_defaults(EntityInterface $entity, $operation = 'defau $form_state['build_info']['callback'] = array($controller, 'build'); $form_state['build_info']['base_form_id'] = $entity->entityType() . '_form'; $form_state['build_info']['args'] = array($entity); - $form_state['langcode'] = empty($langcode) ? language(LANGUAGE_TYPE_CONTENT)->langcode : $langcode; + $form_state['langcode'] = $langcode; return $form_state; } diff --git a/core/modules/entity/lib/Drupal/entity/EntityFormController.php b/core/modules/entity/lib/Drupal/entity/EntityFormController.php index aefa135..0cef405 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityFormController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityFormController.php @@ -209,20 +209,21 @@ class EntityFormController implements EntityFormControllerInterface { */ public function getFormLangcode($form_state) { $entity = $this->getEntity($form_state); - $langcode = FALSE; + $translations = $entity->translations(); - if (language_multilingual()) { + if (!empty($form_state['langcode'])) { $langcode = $form_state['langcode']; - $translations = $entity->translations(); - $fallback = language_fallback_get_candidates(); - - while (!empty($langcode) && !isset($translations->data[$langcode])) { + } + else { + // If the site is not multilingual or no translation for the given form + // language is available, fall back to the entity language. + $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode; + $fallback = language_multilingual() ? language_fallback_get_candidates() : array(); + while (!empty($langcode) && !isset($translations[$langcode])) { $langcode = array_shift($fallback); } } - // If the site is not multilingual or no translation for the given form - // language is available, fall back to the entity language. return !empty($langcode) ? $langcode : $entity->language(); }