I created an entity in a module, using code. I generated skeletons with drupal console generate:entity:content
(without bundles), and then added a datetime field to my TestFieldEntityItem.php, in baseFieldDefinitions()
.
$fields['test_date_incode'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Test date'))
->setDescription(t('Test.'))
->setRevisionable(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'datetime_default',
'settings' => [
'format_type' => 'medium',
],
'weight' => 14,
])
->setDisplayOptions('form', [
'type' => 'datetime',
'weight' => 14,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
I can add data to my entity, without problem, but if I want to add another field (a simple text field) through the UI, I get this error:
Un problème est survenu à la création du champ test_text : The "datetime" plugin does not exist.
(In English, the error message is A problem occurred creating field test_text: The "datetime" plugin does not exist.)
The field is created, but I don't like this error. It seems my code to create the datetime field is not the right one. I use the Calendar module, if this could have any incidence.