Adding values to a cckfield of type node_referencelist is not supported

Comments

clemens.tolboom’s picture

Assigned: Unassigned » clemens.tolboom
Priority: Critical » Normal

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'.

I hope someone has time to find out why.

clemens.tolboom’s picture

See #187599: Fields should provide dummy content upon request for a small discussion about devel vs cck

panis’s picture

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

The functional below also supports multi-select.

function node_factory_set_noderef_value_select( &$edit, $name, $value){ 
//  $edit[ 'field_'. $name][] = array('nid' => $value);
  $edit[ 'field_'. $name]['nids'][$value] = $value;

}
clemens.tolboom’s picture

Thanks. 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.

clemens.tolboom’s picture

When #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.

flebas’s picture

I 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

clemens.tolboom’s picture

clemens.tolboom’s picture

Status: Active » Closed (duplicate)