Last active
December 5, 2018 12:56
-
-
Save JeromeChevalier/374aabf973d696c43faa1af5918ca41b to your computer and use it in GitHub Desktop.
Create a entity basefield with an entity reference type #drupal8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fields['physical_location'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Physical Location')) | |
->setDescription(t('Reference the idenfication number of a physical location')) | |
->setRevisionable(FALSE) | |
->setSetting('target_type', 'site_entity') | |
->setSetting('handler', 'default') | |
->setTranslatable(FALSE) | |
->setDisplayOptions('form', [ | |
'type' => 'entity_reference_autocomplete', | |
'settings' => [ | |
'match_operator' => 'CONTAINS', | |
'size' => 50, | |
'placeholder' => t('Enter identification number of label'), | |
], | |
]) | |
->setDisplayOptions('view', [ | |
'label' => t("Physical Location"), | |
'type' => 'string', | |
]) | |
->setDisplayConfigurable('form', TRUE) | |
->setDisplayConfigurable('view', TRUE); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment