I'm trying to add nodes via a JSON feed. However, I'm having trouble setting the value of a select list field.
I have this at the moment:
$node->field_name[0]['nid'] = $drupal_array[trim($branch[0])]
Which when I output the node object at the end of execution works correctly but when it comes saving the node this individual field isn't saving at all.
Would anyone be able to tell me what I'm doing wrong. I can paste more code if you need it.
$drupal_array
is used to convert the text input of $branch[0]
to a numerical value.
This is the inserted value.
["field_name"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
int(193)
}
}
This is the renderable array output of the same field.
["field_name"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
string(3) "193"
}
}
$node = node_load($nid
) and thendpr($node);
if you have devel enabled. If not,var_dump()
. – Mołot Aug 22 at 13:43