For a current project our taxonomy terms need a text field with a summary; naturally as there's already a body field available on nodes, I thought I'd just use that.
Confusingly, 'body' doesn't appear in the list of existing fields when managing fields for the taxonomy term. No problem thought I, I'll just use field_create_instance()
and add it manually. Drupal objected:
Attempt to create an instance of field body on forbidden entity type taxonomy_term.
So I thought I'd get clever. I loaded up the field config, added taxonomy_term to the array of entity_types, and tried to update with field_update_field()
. Nope:
Cannot change an existing field's entity_types property.
It turns out node_add_body_field()
does this unconditionally:
$field = array(
'field_name' => 'body',
'type' => 'text_with_summary',
'entity_types' => array('node'),
);
$field = field_create_field($field);
I (perhaps naively, not sure yet) disagreed with Drupal's various assessments, so I went into the database and manually added taxonomy_term to the list of allowed entity types for the body field. Works great, I haven't noticed any ill-effects so far, and the body field is where I expect it to be.
So I guess my question is two-fold:
- What reason could there be for the node module locking down this field to a single entity type?
- Can I expect to see any bad effects from this further down the line?