function entity_reference_test_entity_base_field_info_alter

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module \entity_reference_test_entity_base_field_info_alter()
  2. 8.9.x core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module \entity_reference_test_entity_base_field_info_alter()
  3. 11.x core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module \entity_reference_test_entity_base_field_info_alter()

Implements hook_entity_base_field_info_alter().

File

core/modules/system/tests/modules/entity_reference_test/entity_reference_test.module, line 31

Code

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', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 0,
    ])
      ->setDisplayConfigurable('form', TRUE);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.