Hi!
I tried to populate content's node reference field by this php code in different events:

return array(
  0 => array(
    'value' => $node-> nid,
  ),
);

or

return array(
  0 => array(
    'value' => $node-> mynodereferencefield[0][value],
  ),
);

or

return array(
  0 => array(
    'value' => $node-> mynodereferencefield[0][nid],
  ),
);

And now I see this code don't work nowhere.
So how I can set default php value of node reference?

Comments

Daniel A. Beilinson’s picture

Title: Populate referenced content's node reference field » Default php value of node reference field
Daniel A. Beilinson’s picture

Status: Active » Closed (fixed)

Sorry!
Solution for fools like me:

return array(
  0 => array(
    'nid' => $node-> mynodereferencefield[0][nid],
  ),
);

Just forget to change 'value' to 'nid'. :-(

junro’s picture

Status: Closed (fixed) » Active

Hello, but if you want to load another cck node reference field ?

$noderefnode = node_load($field_lien_tournament[0][nid]);
$value = $noderefnode->field_winner[0]['nid'];

return array(
0=>array('nid'=>$value)
);

This doesn't work.

Any idea?