Hello,

I have some problems with setting a default value for a CCK field;

- I have a content type named "Part"
- This content type has a CCK field named "Manufacturer" which its data should refer to another node of type "manufacturer".
- I want to use a PHP snippet to set the default value for this field. I use this snippet:

first I tried to return the node id but it didn't work, field remains empty:

return array(0 => array('value' => 19));

then i tried to return the node alias:

return array(0 => array('value' => 'wheel'));

it didn't work either.

Do you have any idea how can I set a default value for a "Node Reference" field?
Note that i can set a default value for a simple text field or such, but same way doesn't work for Node References.

Thank you in advance.

Comments

yched’s picture

Status: Active » Fixed

Look at the help text provided below the "PHP default value" textarea.
return array(0 => array('nid' => 19));
is what you need for noderef fields

Anonymous’s picture

Status: Fixed » Closed (fixed)