I got an issue in node_save in Drupal.
Below is my code:
function retrax_notify_create(){
$nodeId = array();
$nodeObj = new stdClass(); // We create a new node object
$nodeObj->type = "re_trax_comments_and_notes"; // Or any other content type you want
$nodeObj->title = "Re-Trax Comments";
$nodeObj->language = LANGUAGE_NONE;
node_object_prepare($nodeObj); // Set some default values.
$nodeObj->uid = 474;
$nodeObj->field_userid_ref['und'][0]['value'] = '5';
$nodeObj->field_siteid_ref['und'][0]['value'] = '6';
$nodeObj->field_notify_count['und'][0]['value'] = 7;
$nodeObj = node_submit($nodeObj);
node_save($nodeObj);
$nodeId[nid] = $nodeObj->nid;
echo '<pre>';
print_r($nodeObj);
return $nodeId;
}
When I run the hook menu, default values like type, title, uid will be stored in node table and node id will also get generated.
But the values for other three tables will not get saved for
- field_data_field_userid_ref
- field_data_field_siteid_ref
- field_data_field_notify_count
Database column of one of the tables is shown below
field_userid_ref_value varchar(255) Yes NULL
All the content types are proper but still the value is not being saved to the respective tables.
What am I doing wrong?