Created
September 21, 2018 14:21
-
-
Save lkacenja/94d7587f3f154cc67a170260c8c26b84 to your computer and use it in GitHub Desktop.
Update a basefield definition for an existing entity.
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
<?php | |
use Drupal\Core\Field\BaseFieldDefinition; | |
$definition_manager = \Drupal::entityDefinitionUpdateManager(); | |
$field_storage_definition = $definition_manager->getFieldStorageDefinition('alternate_payment', 'spending_request'); | |
// IF THIS IS UPDATING AN EXISTING FIELD | |
// $definition_manager->uninstallFieldStorageDefinition($field_storage_definition); | |
$new_field = BaseFieldDefinition::create('integer') | |
->setLabel(t('Alternate Payment')) | |
->setDescription(t('Track spending requests that do not have internal payments.')) | |
->setDisplayOptions('view', [ | |
'label' => 'hidden', | |
'type' => 'number_integer', | |
'weight' => 0, | |
]) | |
->setDisplayOptions('form', [ | |
'type' => 'number', | |
'weight' => 0, | |
]) | |
->setDisplayConfigurable('form', TRUE) | |
->setDisplayConfigurable('view', TRUE); | |
$definition_manager->installFieldStorageDefinition('alternate_payment', 'spending_request', 'spending_request', $new_field ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment