diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php index ad8da82..d388be4 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php @@ -46,7 +46,7 @@ class EntityReferenceAutocompleteTest extends EntityUnitTestBase { * * @var array */ - public static $modules = array('entity_reference'); + public static $modules = array('entity_reference', 'entity_reference_test'); public static function getInfo() { return array( diff --git a/core/modules/entity_reference/tests/modules/entity_reference_test/entity_reference_test.module b/core/modules/entity_reference/tests/modules/entity_reference_test/entity_reference_test.module index 37dc050..2013fd1 100644 --- a/core/modules/entity_reference/tests/modules/entity_reference_test/entity_reference_test.module +++ b/core/modules/entity_reference/tests/modules/entity_reference_test/entity_reference_test.module @@ -4,3 +4,21 @@ * @file * Helper module for the Entity Reference tests. */ + +use Drupal\Core\Entity\EntityTypeInterface; + +/** + * Implements hook_entity_base_field_info_alter(). + */ +function entity_reference_test_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) { + if ($entity_type->id() === 'entity_test') { + // Allow user_id field to use configurable widget. + $fields['user_id'] + ->setSetting('handler', 'default') + ->setDisplayOptions('form', array( + 'type' => 'entity_reference_autocomplete', + 'weight' => 0, + )) + ->setDisplayConfigurable('form', TRUE); + } +} diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php index 94c05cc..d55bb8d 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php @@ -139,17 +139,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['user_id'] = FieldDefinition::create('entity_reference') ->setLabel(t('User ID')) ->setDescription(t('The ID of the associated user.')) - ->setSettings(array( - 'target_type' => 'user', - 'handler' => 'default', - )) - ->setTranslatable(TRUE) - ->setRequired(TRUE) - ->setDisplayOptions('form', array( - 'type' => 'entity_reference_autocomplete', - 'weight' => -10, - )) - ->setDisplayConfigurable('form', TRUE); + ->setSettings(array('target_type' => 'user')) + ->setTranslatable(TRUE); return $fields; } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index 89eecea..749ee44 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -31,6 +31,16 @@ public function form(array $form, array &$form_state) { '#weight' => -10, ); + $form['user_id'] = array( + '#type' => 'textfield', + '#title' => 'UID', + '#default_value' => $entity->user_id->target_id, + '#size' => 60, + '#maxlength' => 128, + '#required' => TRUE, + '#weight' => -10, + ); + $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select',