made event fields configurable

This commit is contained in:
Nick 2022-04-15 16:44:59 +02:00
parent 8c3f2bcbc3
commit aa6d580d62

View File

@ -149,7 +149,9 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
->setDescription(t('The user ID of author of the Event entity.')) ->setDescription(t('The user ID of author of the Event entity.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSetting('target_type', 'user') ->setSetting('target_type', 'user')
->setSetting('handler', 'default'); ->setSetting('handler', 'default')
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true);
$fields['name'] = BaseFieldDefinition::create('string') $fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name')) ->setLabel(t('Name'))
@ -163,15 +165,16 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
'type' => 'string_textfield', 'type' => 'string_textfield',
'weight' => -4, 'weight' => -4,
]) ])
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', TRUE) ->setDisplayConfigurable('view', true)
->setRequired(TRUE); ->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean') $fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Visible')) ->setLabel(t('Visible'))
->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.') ->setDescription('If this box is not ticked this record will be hidden from view for most users. Users with access to unpublished entities will be able to restore it if needed.')
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setDisplayConfigurable("form", true) ->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDefaultValue(TRUE); ->setDefaultValue(TRUE);
@ -190,18 +193,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
->setRequired(TRUE) ->setRequired(TRUE)
// Uses the currentDateTime function from the Activity entity // Uses the currentDateTime function from the Activity entity
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime') ->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [ ->setDisplayConfigurable('form', true)
'label' => 'above', ->setDisplayConfigurable('view', true);
'type' => 'datetime_default',
'settings' => [
'format_type' => 'medium',
],
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'datetime_default',
'weight' => -3,
]);
$fields['description'] = BaseFieldDefinition::create('string_long') $fields['description'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Description')) ->setLabel(t('Description'))
@ -211,15 +204,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
'text_processing' => 0, 'text_processing' => 0,
]) ])
->setDefaultValue('') ->setDefaultValue('')
->setDisplayOptions('view', [ ->setDisplayConfigurable('form', true)
'label' => 'above', ->setDisplayConfigurable('view', true)
'type' => 'basic_string',
'weight' => -1,
])
->setDisplayOptions('form', [
'type' => 'string_textarea',
'weight' => -1,
])
->setRequired(FALSE); ->setRequired(FALSE);
$fields['attendees'] = BaseFieldDefinition::create('entity_reference') $fields['attendees'] = BaseFieldDefinition::create('entity_reference')
@ -229,14 +215,8 @@ class OCEvent extends ContentEntityBase implements OCEventInterface {
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [ ->setDisplayConfigurable('form', true)
'type' => 'string', ->setDisplayConfigurable('view', true)
'weight' => 50,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 50,
])
->setRequired(FALSE); ->setRequired(FALSE);