diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 350ed5d..00b92c3 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -6,6 +6,8 @@ */ use Drupal\Component\Utility\String; +use Drupal\Core\Entity\ContentEntityType; +use Drupal\Core\Entity\EntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -182,10 +184,18 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_ foreach ($language as $element_name => $values) { $entityType = $values['entity_type']; $bundle = $values['bundle']; - // In case we are editing the node, we must check the new entity type, - // because language_node_type_update fired before. - if ($form['#id'] == 'node-type-edit-form') { - $bundle = $form_state->getValue('type'); + // In case we are editing a bundle, we must check the new bundle name, + // because e.g. language_node_type_update fired before. + // A way of checking if the form is an edit form is checking for the + // delete action presence. + $form_object = $form_state->getFormObject(); + if ($form_object instanceof EntityForm && $form_object->getOperation() === 'edit') { + /** @var EntityForm $form_object */ + $entity = $form_object->getEntity(); + $entity_definition = Drupal::entityManager()->getDefinition($entityType); + if ($entity_definition instanceof ContentEntityType) { + $bundle = $entity->id(); + } } /** @var ContentLanguageSettings $config */ $config = ContentLanguageSettings::loadByEntityTypeBundle($entityType, $bundle);