Added "files" as base field on case

This commit is contained in:
naomi 2018-05-07 15:04:01 +02:00
parent 18d0303f54
commit 7dc3e5d563

View File

@ -228,7 +228,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'inline', 'label' => 'inline',
'type' => 'author', 'type' => 'author',
'weight' => -3, 'weight' => -4,
]); ]);
$fields['name'] = BaseFieldDefinition::create('string') $fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name')) ->setLabel(t('Name'))
@ -242,11 +242,11 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'hidden', 'label' => 'hidden',
'type' => 'string', 'type' => 'string',
'weight' => -2, 'weight' => -3,
]) ])
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -2, 'weight' => -3,
]) ])
->setRequired(TRUE); ->setRequired(TRUE);
@ -259,7 +259,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
->setCardinality(-1) ->setCardinality(-1)
->setDisplayOptions('form', [ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete', 'type' => 'entity_reference_autocomplete',
'weight' => -1, 'weight' => -2,
'settings' => [ 'settings' => [
'match_operator' => 'CONTAINS', 'match_operator' => 'CONTAINS',
'size' => '60', 'size' => '60',
@ -269,11 +269,31 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
]) ])
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'weight' => -1 'weight' => -2
]) ])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCCase::defaultVal') ->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCCase::defaultVal')
->setRequired(TRUE); ->setRequired(TRUE);
$fields['files'] = BaseFieldDefinition::create('file')
->setLabel(t('Files'))
->setDescription(t('Files attached to this case'))
->setSetting('file_directory', '[date:custom:Y]-[date:custom:m]')
->setSetting('handler', 'default:file')
->setSetting('file_extensions', 'txt jpg jpeg gif rtf xls xlsx doc swf png pdf docx csv')
->setSetting('description_field', 'true')
->setCardinality(-1)
->setDisplayOptions('form', [
'type' => 'file_generic',
'weight' => -1,
'settings' => [
'progress_indicator' => 'throbber',
],
])
->setDisplayOptions('view', [
'label' => 'above',
'weight' => -1,
'settings' => ['use_description_as_link_text' => 'true']
]);
$fields['created'] = BaseFieldDefinition::create('created') $fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created')) ->setLabel(t('Created'))