I have defined my own entity: 'game'; created some 'games' with entity_create; and loaded one of these 'games' into a form for editing. Now, I want to update the entity with my submit handler. Here is the relevant code inside the handler:

$game = entity_load_single('game', $form_state['values']['game_id']);
$wrapper = entity_metadata_wrapper('game', $game);

This throws:


EntityMetadataWrapperException: Entity property some_property doesn't support writing. in EntityStructureWrapper->setProperty() (line 493 of /.../sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

I was looking for a function like entity_update, but it doesn't seem to exist. How can I update my 'game' entities? Thanks.

2 Answers 2


You're probably looking for entity_save().

If you want to use a metadata wrapper for a custom entity properties you need to implement hook_entity_property_info() to describe them to the entity module, especially setter callbacks which are used to set the value of the property.


If you created your entity via entity_create (as you mentioned), you can set/override non-writable properties outside of the entity wrapper during the entity creation, e.g.

$entity = entity_create('games',
      'type' => 'game', 
      'changed' => REQUEST_TIME,     
      'some_property' => 'some value',        
$wrapper = entity_metadata_wrapper('game', $entity);  

Otherwise you'll need to write your own setter callback as already suggested.

See also: How to fix entity property X doesn't support writing, when setting content type field values?

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.