I've got a D7 content type with a few fields; nothing particularly special. I want to be able to programattically change the values of those fields from time to time, and so wrote a function like so:

function set_field_value($field_name, $node, $value) {
    $wrapper = entity_metadata_wrapper('node', $node->nid);
    $wrapper->$field_name = $value;

This worked in a few test cases (like changing the title of a blog node), but when I try it on content type fields, I get an error like:

EntityMetadataWrapperException: Entity property field_project_video_status_yt doesn't support writing. in EntityStructureWrapper->setProperty() (line 497 of ...)

What I'm doing wrong?

  • What is the type of the field on which you're getting the error ? Apr 11, 2013 at 17:40
  • The field is type = computed.
    – Jim Miller
    Apr 11, 2013 at 18:27
  • Aha -- down in computed_field.module there is computed_field_entity_property_callback(), which says "The only thing is that a setter doesn't make sense, so let's disable it", and proceeds to do so. So that's probably it. I'll try some experiments, but can you think of an obvious way to reenable the setter, ideally without hacking the module's source :)?
    – Jim Miller
    Apr 11, 2013 at 19:12
  • FWIW, commenting out the two lines in computed_field_entity_property_callback() that claim to disable the setter does indeed re-enable the setter, and my code works. I'll take it from here with the computed_field folks.
    – Jim Miller
    Apr 11, 2013 at 20:59

2 Answers 2


Short Answer: It is not possible to write to that field type using entity metadata wrappers. You may want to raise the issue with the maintainers of the module that provide that field type.

Long Answer: The Entity Metadata Wrapper you are using is provided by the Entity Module. This module extends Drupal's entities in various ways. One of the things it offers is to extend the information about fields, by offering it's own hook, hook_entity_property_info. This hook allows, amongst other things, to define a setter callback. This is the function that is used by the entity meta data wrapper to set the value of a field or property.

The error you are seeing implies that this function is missing for the field type you are trying to access.

The Entity module itself actually provides a default function for fields that do not define their own setter callback. What this means is that :

  • Either the module that creates the field you're using implements hook_entity_property_info and does not define a setter callback; or

  • Another module explicitely removes the setter callback from the field type you are using.

Either way, you cannot use entity_metadata_wrapper for that field type until the issue is resolved. You should raise it with the people who maintain the module providing that field type.


I unfortunately don't have enough reputation to simply comment after Alice perfect answer. I just wanted to add this:

I thought the setter callback default value was set to "entity_property_verbatim_set" so I didn't bother adding this to my properties. It turns out, you still need it to avoid that error.

Thanks Alice!

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.