I have a custom entity with (among others) a field defined this way:
$fields['duedate'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Due Date'))
->setSetting('datetime_type', 'date')
->setDefaultValue(array(0 => array(
'default_date_type' => 'now',
'default_date' => '2050-12-31',
)))
->setDisplayOptions('view', [
'type' => 'datetime_default',
'settings' => [
'format_type' => 'date_courte',
],
'weight' => 5,
])
->setDisplayOptions('form', array(
'weight' => 5,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
'date_courte' is a custom date format I created to display date as 'dd/mm/yyyy'. And it works!
I'd like to have the same result without using 'date_courte' so I tried
'settings' => [
'format_type' => 'custom',
'format' => 'd/m/Y',
],
instead of
'settings' => [
'format_type' => 'date_courte',
],
And it doesn't work!
I'm pretty sure of 'format_type' => 'custom'
.
I think the problem comes from 'format' in 'format' => 'd/m/Y'
.
What should be the correct syntax?