I am having trouble updating custom fields programmatically. The code appears below and is in the body of my custom module. When I run this changing the title, it changes OK. But, when I try to do this with the custom field, the field doesn't get updated and I don't understand why. Should I be wrapping this into some hook? Is there a cache not being cleared somewhere? Basically, what am I missing when it comes to programmatically updating fields.
$nodes_to_load = $query->execute();
if (isset($nodes_to_load['node'])) {
$nodes = entity_load('node', array_keys($nodes_to_load['node']));
foreach ($nodes as $node) {
$node->field_myother_field[$node->language][]['value'] = '500';
$node->title = "retest the test";
node_save($node);
}
}
else {
print "no nodes to load";
}
UPDATE: When I try to change the field by going into the admin panel, and simply typing in a new value I get a "The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved" error.