简体   繁体   中英

edit drupal 6 node reference field value

I am working on a custom drupal module that would change a node's node reference field value dynamically if a user clicks on an AJAX button.

In my callback function I could load the two nodes, A and B, where A has a node reference CCK field named 'foobar'.

How can I set edit and save this field? This is my attempt, but if I refresh the node, the field doesn't get updated.

$A_node = node_load($a_nid);
$B_node = node_load($b_nid);
$A_node->field_foobar[0]['nid'] = $b_nid;
node_save($A_node);

使用此处提到的vid保存节点,如果是这里提到的缓存问题,也可以

To save CCK fields, you need to call more than one function to save the complete node.

content_presave($node);
node_save($node);
content_insert($node);

Try this you might get all data inserted into database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM