function EntityReferenceTestHooks::entityBaseFieldInfoAlter

Implements hook_entity_base_field_info_alter().

File

core/modules/system/tests/modules/entity_reference_test/src/Hook/EntityReferenceTestHooks.php, line 31

Class

EntityReferenceTestHooks
Hook implementations for entity_reference_test.

Namespace

Drupal\entity_reference_test\Hook

Code

public function entityBaseFieldInfoAlter(&$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.