I would like to add some custom fields to the taxonomy_term_data table.

How do I programmatically extend the Term entity?

1 Answer 1


There is a hook for that hook_entity_base_field_info(). The code could look something like this

 * Implements hook_entity_base_field_info().
function module_name_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'taxonomy_term') {
    $fields['new_field'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')

    // You can add more options about visibility configuration etc.

    return $fields;

The above could add "hidden" field, (not visible in display or edit mode and not configurable). You need to do the same thing as when creating base fields in a custom entity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.