function EntityTestBaseFieldDisplay::baseFieldDefinitions
Same name in other branches
- 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay::baseFieldDefinitions()
- 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay::baseFieldDefinitions()
- 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay::baseFieldDefinitions()
Overrides EntityTest::baseFieldDefinitions
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestBaseFieldDisplay.php, line 47
Class
- EntityTestBaseFieldDisplay
- Defines a test entity class for base fields display.
Namespace
Drupal\entity_test\EntityCode
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['test_no_display'] = BaseFieldDefinition::create('text')->setLabel(t('Field with no display'));
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with configurable display'))
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 10,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 10,
])
->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with non-configurable display'))
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 11,
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 11,
]);
$fields['test_display_multiple'] = BaseFieldDefinition::create('text')->setLabel(t('A field with multiple values'))
->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 12,
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 12,
]);
return $fields;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.