Programmatically create a term reference entity field

An example of programmatically creating a term reference entity field:
$fields[] = BaseFieldDefinition::create('entity_reference')
 ->setSetting('target_type', 'taxonomy_term')
 ->setTargetEntityTypeId(<vocabulary machine name>);


Add new comment


  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Missing filter. All text is removed
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.