diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index af7b5fc..9472ebb 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -66,34 +66,6 @@ function entity_reference_get_selection_handler(FieldDefinitionInterface $field_ } /** - * Implements hook_field_settings_form(). - */ -function entity_reference_field_settings_form($field, $instance) { - // Select the target entity type. - $entity_type_options = array(); - foreach (entity_get_info() as $entity_type => $entity_info) { - // @todo As the database schema can currently only store numeric IDs of - // referenced entities and configuration entities have string IDs, prevent - // configuration entities from being referenced. - if (!is_subclass_of($entity_info['class'], '\Drupal\Core\Config\Entity\ConfigEntityInterface')) { - $entity_type_options[$entity_type] = $entity_info['label']; - } - } - - $form['target_type'] = array( - '#type' => 'select', - '#title' => t('Type of item to reference'), - '#options' => $entity_type_options, - '#default_value' => $field['settings']['target_type'], - '#required' => TRUE, - '#disabled' => $field->hasData(), - '#size' => 1, - ); - - return $form; -} - -/** * Implements hook_ENTITY_TYPE_update() for 'field_entity'. * * Reset the instance handler settings, when the target type is changed. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php index 956a968..fc3d4f7 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/field_type/ConfigurableEntityReferenceItem.php @@ -115,4 +115,34 @@ public function getConstraints() { return $constraints; } + /** + * {@inheritdoc} + */ + public function settingsForm(array $form, array &$form_state) { + $field = $this->getInstance()->getField(); + + // Select the target entity type. + $entity_type_options = array(); + foreach (entity_get_info() as $entity_type => $entity_info) { + // @todo As the database schema can currently only store numeric IDs of + // referenced entities and configuration entities have string IDs, prevent + // configuration entities from being referenced. + if (!is_subclass_of($entity_info['class'], '\Drupal\Core\Config\Entity\ConfigEntityInterface')) { + $entity_type_options[$entity_type] = $entity_info['label']; + } + } + + $element['target_type'] = array( + '#type' => 'select', + '#title' => t('Type of item to reference'), + '#options' => $entity_type_options, + '#default_value' => $field->settings['target_type'], + '#required' => TRUE, + '#disabled' => $field->hasData(), + '#size' => 1, + ); + + return $element; + } + }