v1.7 - adding datetime field with correct datepicker type & default datetime

This commit is contained in:
Naomi 2020-02-24 10:57:06 +00:00
parent c63cae6b71
commit f47ded38fa
2 changed files with 1 additions and 18 deletions

View File

@ -1,15 +1,5 @@
<?php <?php
function opencase_entities_update_8013() {
$update_manager = \Drupal::entityDefinitionUpdateManager();
$definition = $update_manager->getFieldStorageDefinition('activity_date_time', 'oc_activity');
// $definition->setDescription('');
// $definition->setRequired('');
//->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
$update_manager->updateFieldStorageDefinition($definition);
}
/** /**
* Add 'activity_date_time' field to 'oc_activity' entities. * Add 'activity_date_time' field to 'oc_activity' entities.
*/ */
@ -18,10 +8,7 @@ function opencase_entities_update_8003() {
->setLabel(t('Date and time')) ->setLabel(t('Date and time'))
->setDescription(t('When the activity started.')) ->setDescription(t('When the activity started.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSettings([ ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
'datetime_type' => 'date'
])
->setDefaultValue('2000-01-01')
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'type' => 'datetime_default', 'type' => 'datetime_default',
'settings' => [ 'settings' => [

View File

@ -87,7 +87,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
$current_time = DrupalDateTime::createFromTimestamp(time()); $current_time = DrupalDateTime::createFromTimestamp(time());
$formatted = $current_time->format(DateTimeItem::DATETIME_STORAGE_FORMAT); $formatted = $current_time->format(DateTimeItem::DATETIME_STORAGE_FORMAT);
\Drupal::logger("nr_debug")->notice($formatted); \Drupal::logger("nr_debug")->notice($formatted);
$formatted="2010-10-10";
return $formatted; return $formatted;
} }
/** /**
@ -224,9 +223,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDescription('') ->setDescription('')
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setRequired(TRUE) ->setRequired(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime') ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',