I've set my taxonomy description field to taking a filtered text value. Using the UI, I can edit a taxonomy term, write some HTML, save, and when I view it I see the HTML rendered by my browser.

However when doing this:

$wrapper = entity_metadata_wrapper('taxonomy_term', 123);
$wrapper->description->set('<p>My html</p>');

And viewing the term's page, the description comes out with the html converted to entities, i.e. I see <p>My html</p> instead of a paragraph with My html as its content.

I notice that

$wrapper->description->value(); // <p>&lt;p&gtp;My html&lt;p&gt;</p>

Whereas if I load a term that I have edited with the UI, saving HTML to the description field,

$wrapper->description->value(); // <p>Some html</p>

I've looked at $wrapper->description and $wrapper->value()->description and there's no difference between a term with/without the correct/desired behaviour.

Also, I note that with normal fields, when you set a formatted text field you pass/get an array [ 'format' => 'filtered', 'value' => '<p>the html</p>' ] whereas here I only ever get a string.

Is this something peculiar to taxonomy terms (and is there a workaround or extra code I need)? Have I misunderstood something?


1 Answer 1


I just encountered a similar situation myself and it looks like you're choices are either taxonomy_term_save() or to update the table directly via db_update(). The format property belongs to the term itself, rather than the Description property of the term. If you execute $term->getPropertyInfo() you'll see that the format property is not returned. Keep in mind that the Description is a property of the taxonomy entity, rather than a field, but doesn't seem to be accessible via EMW.


  'tid' => $tid,
  'description' => $t($descriptions[$info['step']]),
  'format' => 'full_html',
  'vid' => $vocab->vid,
  • Thanks for this work around. Strange how the wrapper can't deal with this. Oct 3, 2016 at 6:30

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.