This is the code I execute with "Execute PHP" with the Devel module.
$lang = LANGUAGE_NONE; // Replace with ISO639-2 code if localizing
$node_type = 'my_writings'; // Machine name of the content type
$query = new EntityFieldQuery;
$result = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', $node_type)
->execute();
if (!empty($result['node'])) {
$nodes = entity_load('node', array_keys($result['node']));
foreach($nodes as $node) {
$str=<<<END
<h3> TITLE</h3>
<p>
Hello world.
</p>
END;
// Replace field_foo with the machine name of the field to update.
// - 0 refers to specific within the field array, for when the field contains
// multiple values. If the field only has one value, it should be 0.
$node->field_author_box[$lang][0]['value'] = $str;
node_save($node);
}
}
The output I get is this HTML code like this.
<h3> TITLE</h3>
<p>
Hello world.
</p>
The input format is set to Full HTML, but the HTML tags are shown escaped, even if in the database they appear normal.
I tried to re-save the node; then, it is normal. I tried also to use html_entity_decode()
without luck, if I do the same with body field then it works fine, but with a new field its showing escaped characters.
What could the problem be?