Set label of Contact Details entity to its type
Also made some trivial changes
This commit is contained in:
parent
599ee239ff
commit
190a90a4db
@ -45,7 +45,7 @@ use Drupal\user\UserInterface;
|
|||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
* "id" = "id",
|
* "id" = "id",
|
||||||
* "revision" = "vid",
|
* "revision" = "vid",
|
||||||
* "label" = "name",
|
* "label" = "type",
|
||||||
* "uuid" = "uuid",
|
* "uuid" = "uuid",
|
||||||
* "uid" = "user_id",
|
* "uid" = "user_id",
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
@ -171,6 +171,7 @@ class ContactDetails extends RevisionableContentEntityBase implements ContactDet
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
->setDisplayConfigurable('view', TRUE);
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOwner(UserInterface $account) {
|
public function setOwner(UserInterface $account) {
|
||||||
@ -207,9 +208,9 @@ class ContactDetails extends RevisionableContentEntityBase implements ContactDet
|
|||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
->setTranslatable(TRUE)
|
->setTranslatable(TRUE)
|
||||||
->setDisplayOptions('view', [
|
->setDisplayOptions('view', [
|
||||||
'label' => 'hidden',
|
'label' => 'inline',
|
||||||
'type' => 'author',
|
'type' => 'author',
|
||||||
'weight' => 0,
|
'weight' => 100,
|
||||||
])
|
])
|
||||||
->setDisplayOptions('form', [
|
->setDisplayOptions('form', [
|
||||||
'type' => 'entity_reference_autocomplete',
|
'type' => 'entity_reference_autocomplete',
|
||||||
@ -220,12 +221,8 @@ class ContactDetails extends RevisionableContentEntityBase implements ContactDet
|
|||||||
'autocomplete_type' => 'tags',
|
'autocomplete_type' => 'tags',
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
],
|
],
|
||||||
])
|
]);
|
||||||
->setDisplayConfigurable('form', TRUE)
|
|
||||||
->setDisplayConfigurable('view', TRUE);
|
|
||||||
|
|
||||||
// This field is not displayed but is used to compute the name of the entity.
|
|
||||||
// See zencrm_entities.module - zencrm_entities_contact_details_presave().
|
|
||||||
$fields['type'] = BaseFieldDefinition::create('entity_reference')
|
$fields['type'] = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Type'))
|
->setLabel(t('Type'))
|
||||||
->setDescription(t('E.g. Home, Business, Temporary'))
|
->setDescription(t('E.g. Home, Business, Temporary'))
|
||||||
@ -249,10 +246,9 @@ class ContactDetails extends RevisionableContentEntityBase implements ContactDet
|
|||||||
->setDisplayOptions('view', [
|
->setDisplayOptions('view', [
|
||||||
'settings' => ['link' => 'false'],
|
'settings' => ['link' => 'false'],
|
||||||
'type' => 'entity_reference_label',
|
'type' => 'entity_reference_label',
|
||||||
'label' => 'above',
|
'label' => 'hidden',
|
||||||
'weight' => 0,
|
'weight' => 0,
|
||||||
])
|
])
|
||||||
->setDisplayConfigurable('view', TRUE)
|
|
||||||
->setRequired(TRUE);
|
->setRequired(TRUE);
|
||||||
|
|
||||||
|
|
||||||
@ -278,32 +274,11 @@ class ContactDetails extends RevisionableContentEntityBase implements ContactDet
|
|||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
->setDisplayOptions('view', [
|
->setRequired(TRUE);
|
||||||
'label' => 'above',
|
|
||||||
'weight' => 0,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
|
||||||
->setLabel(t('Name'))
|
|
||||||
->setDescription(t('The name of the Contact Details entity.'))
|
|
||||||
->setRevisionable(TRUE)
|
|
||||||
->setSettings([
|
|
||||||
'max_length' => 50,
|
|
||||||
'text_processing' => 0,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('view', [
|
|
||||||
'label' => 'above',
|
|
||||||
'type' => 'string',
|
|
||||||
'weight' => -4,
|
|
||||||
])
|
|
||||||
->setDisplayOptions('form', [
|
|
||||||
'type' => 'string_textfield',
|
|
||||||
'weight' => -4,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Publishing status'))
|
->setLabel(t('Enabled'))
|
||||||
->setDescription(t('A boolean indicating whether the Contact Details is published.'))
|
->setDescription(t('If this is ticked then this set of contact details is active.'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setDefaultValue(TRUE)
|
->setDefaultValue(TRUE)
|
||||||
->setDisplayOptions('form', [
|
->setDisplayOptions('form', [
|
||||||
|
Reference in New Issue
Block a user