v1.6 Added activity date time field
This commit is contained in:
parent
a6db6615df
commit
a7a96ab03c
31
modules/opencase_entities/opencase_entities.install
Normal file
31
modules/opencase_entities/opencase_entities.install
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add 'activity_date_time' field to 'oc_activity' entities.
|
||||
*/
|
||||
function opencase_entities_update_8003() {
|
||||
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
|
||||
->setLabel(t('Date and time'))
|
||||
->setDescription(t('When the activity started.'))
|
||||
->setRevisionable(TRUE)
|
||||
->setSettings([
|
||||
'datetime_type' => 'date'
|
||||
])
|
||||
->setDefaultValue('2000-01-01')
|
||||
->setDisplayOptions('view', [
|
||||
'type' => 'datetime_default',
|
||||
'settings' => [
|
||||
'format_type' => 'medium',
|
||||
],
|
||||
'label' => 'above',
|
||||
'weight' => -3,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'datetime_default',
|
||||
'weight' => -3,
|
||||
]);
|
||||
|
||||
\Drupal::entityDefinitionUpdateManager()
|
||||
->installFieldStorageDefinition('activity_date_time', 'oc_activity', 'oc_activity', $storage_definition);
|
||||
}
|
||||
|
@ -210,6 +210,27 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
$fields['activity_date_time'] = BaseFieldDefinition::create('datetime')
|
||||
->setLabel(t('Date and time'))
|
||||
->setDescription(t('When the activity started.'))
|
||||
->setRevisionable(TRUE)
|
||||
->setSettings([
|
||||
'datetime_type' => 'date'
|
||||
])
|
||||
->setDefaultValue('2000-01-01')
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'above',
|
||||
'type' => 'datetime_default',
|
||||
'settings' => [
|
||||
'format_type' => 'medium',
|
||||
],
|
||||
'weight' => -3,
|
||||
])
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'datetime_default',
|
||||
'weight' => -3,
|
||||
]);
|
||||
|
||||
// not currently in use. Will set view and form settings when ready
|
||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||
->setLabel(t('Publishing status'))
|
||||
|
@ -2,6 +2,7 @@ name: 'OpenCase'
|
||||
type: module
|
||||
description: 'Simple Case Management'
|
||||
core: 8.x
|
||||
version: 8.x-1.6
|
||||
package: 'OpenCase'
|
||||
dependencies:
|
||||
- opencase_entities
|
||||
|
Reference in New Issue
Block a user