Moved base fields around

Because you can't make it put them at the bottom, so I have given them all negative weights so they go at the top and the custom fields start at 0. User is at the top
This commit is contained in:
naomi
2018-05-07 14:49:31 +02:00
parent c1c981fddd
commit 18d0303f54
3 changed files with 59 additions and 103 deletions

View File

@ -210,30 +210,25 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
// not currently in use. Will set view and form settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Activity is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setLabel(t('Entered by'))
->setDescription(t('The user ID of author of the Activity entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'label' => 'inline',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
'weight' => -3,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -247,14 +242,12 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
'weight' => -2,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
'weight' => -2,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['oc_case'] = BaseFieldDefinition::create('entity_reference')
@ -266,7 +259,7 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
->setCardinality(1)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'weight' => -1,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
@ -274,19 +267,13 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
'placeholder' => '',
],
])
->setDisplayOptions('form', [
'label' => 'above',
'weight' => -1
])
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::defaultVal')
->setRequired(TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Activity is published.'))
->setRevisionable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));