I have created a custom content entity type in a module, which defines the "title" field in the entity definition baseFieldDefinitions() code as follows:
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setTranslatable(TRUE)
->setDescription(t('The name of the item'))
->setSettings(array(
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -6,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -6,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Using pathauto 8.x-1.x-dev, I am attempting to add a Pathauto pattern for this custom content entity type that uses the "title" field. When I select my entity type, and then click "Browse available tokens", the "title" token is absent.
All fields for this entity type defined via the drupal interface are available as tokens, and so is ID, but title is not. This field needs to be defined programmatically as it is part of the entity's entity_keys annotation.
The title field is available as a token for default entity types like node, but not for custom created ones.
Comments
Comment #2
BerdirCan you share the whole class to make it easier to reproduce?
Comment #3
BerdirComment #4
jidrone CreditAttribution: jidrone as a volunteer commentedHi @Berdir,
I have a similar issue, I reproduced this way:
Comment #5
Berdirtoken.module only exposes tokens for base fields for entity types that do *not* define their own tokens, otherwise you would get conflicts and overlaps. So that is by-design.