diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php index 237aff2..440b626 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php @@ -134,11 +134,12 @@ protected function getLabels(array $items) { */ protected function createNewEntity($label, $uid) { $entity_manager = \Drupal::entityManager(); - $target_type = $this->field['settings']['target_type']; + $target_type = $this->getFieldSetting('target_type'); + $target_bundles = $this->getSelectionHandlerSetting('target_bundles'); // Get the bundle. - if (!empty($this->instance['settings']['handler_settings']['target_bundles']) && count($this->instance['settings']['handler_settings']['target_bundles']) == 1) { - $bundle = reset($this->instance['settings']['handler_settings']['target_bundles']); + if (!empty($target_bundles) && count($target_bundles) == 1) { + $bundle = reset($target_bundles); } else { $bundles = entity_get_bundles($target_type);