Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Yeah ... when using a CCK node reference field the assigned value array( array( 'nid'=> 10)) is only accepted when the CCK node reference field is 'autocomplete'.
possible workaround - works for me. create additional function to work with select.. Now may be better potentially could also check automatically to see what field type and set accordingly. or perhaps set both variables? see commented out code below - have not tried that piece though
Comments
Comment #1
clemens.tolboomYeah ... when using a CCK node reference field the assigned value array( array( 'nid'=> 10)) is only accepted when the CCK node reference field is 'autocomplete'.
I hope someone has time to find out why.
Comment #2
clemens.tolboomSee #187599: Fields should provide dummy content upon request for a small discussion about devel vs cck
Comment #3
panis commentedpossible workaround - works for me. create additional function to work with select.. Now may be better potentially could also check automatically to see what field type and set accordingly. or perhaps set both variables? see commented out code below - have not tried that piece though
The functional below also supports multi-select.
Comment #4
clemens.tolboomThanks. Looks great. How did you found out? I'll dive into this probably next week when starting with a project. Have to clear the issue queue anyway.
I'm now trying to make API.module work on the project/demo site.
Comment #5
clemens.tolboomWhen #232121: review of node_factory. is functional this is solved automaticly that is using content_fields
Problem is I have not found a good cck devel resource.
Comment #6
flebas commentedI get node_factory work with nodereference select.
With autocomplete nodereference, I use :
node_factory_set_cck_value($node, 'field_mycckfield', array(array('nid' => $my_nid)));
With select nodereference, I use :
node_factory_set_cck_value($node, 'field_mycckfield', array('nids' => $my_nid));
It should be possible to get this done automatically, but this should be included in CCK that should be included in core.
Frederic
Comment #7
clemens.tolboomI close this in favour of #260971: support for noderef select single / multi
Comment #8
clemens.tolboom