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

welzie’s picture

This is what worked for me with drupal 5.x and cck 5.x-1.7.

return array(0 => array('nid' => 13 ));

Only difference is that I have 'nid' instead of 'value'.

Responding in hopes of helping someone else.

seanmclucas’s picture

replacing 'value' with 'nid' doesn't seem to work either.

shunting’s picture

'value', 'nid', whatever?

and why 0=> .... ???

Maybe it's me, but this is feeling like a complicated thing that ought to be simple.

http://www.universalpantograph.com