function EntityTestWithBundle::baseFieldDefinitions

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle::baseFieldDefinitions()
  2. 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle::baseFieldDefinitions()
  3. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle::baseFieldDefinitions()

Overrides ContentEntityBase::baseFieldDefinitions

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php, line 55

Class

EntityTestWithBundle
Defines the Test entity with bundle entity class.

Namespace

Drupal\entity_test\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))
        ->setDescription(t('The name of the test entity.'))
        ->setTranslatable(TRUE)
        ->setSetting('max_length', 32)
        ->setDisplayOptions('view', [
        'label' => 'hidden',
        'type' => 'string',
        'weight' => -5,
    ])
        ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'weight' => -5,
    ]);
    return $fields;
}

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