Skip to main content
8 events
when toggle format what by license comment
Aug 24, 2021 at 13:33 vote accept Patrick Kenny
Aug 24, 2021 at 11:34 comment added Alireza Tabatabaeian @PatrickKenny, you can use hook_entity_base_field_info_alter api.drupal.org/api/drupal/… to change base field definitions like id or title or ...
Aug 24, 2021 at 10:37 comment added avpaderno @PatrickKenny That's because hook_entity_bundle_field_info_alter() is for bundle fields, while the taxonomy name is a base field, which means it's present in every taxonomy bundle.
Aug 24, 2021 at 10:35 comment added Patrick Kenny @apaderno Thanks, that's very helpful. Unfortunately, in hook_entity_bundle_field_info_alter(), it seems the name field is not available, which is what confused me. Follow-up question here: drupal.stackexchange.com/questions/305789/…
Aug 24, 2021 at 10:19 comment added avpaderno The same is true for the taxonomy term name: $fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setTranslatable(TRUE)->setRevisionable(TRUE)->setRequired(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', ['label' => 'hidden','type' => 'string','weight' => -5,]);
Aug 24, 2021 at 10:17 comment added avpaderno @PatrickKenny The node title is an entity field: $fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setRequired(TRUE)->setTranslatable(TRUE)->setRevisionable(TRUE)->setSetting('max_length', 255)->setDisplayOptions('view', ['label' => 'hidden','type' => 'string','weight' => -5,]); Don't get confused from Drupal showing the page title in a block.
Aug 24, 2021 at 7:34 comment added Patrick Kenny Awesome! This looks like a great way to do it, except the term name is not a field, right? It's like the node/page title-- it's not accessible (as far as I know) as a field. So what do I do in that case?
Aug 24, 2021 at 6:45 history answered Alireza Tabatabaeian CC BY-SA 4.0