How to fix entity property X doesn't support writing, when setting content type field values? 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-&gt;nid);
    $wrapper-&gt;$field_name = $value;
    $wrapper-&gt;save();
}


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?
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.