Hello,

I have 2 content types: "quote" and "contract". Both have the same fields: "field_node_state" (a select box) and "field_products" (a node-reference field).

I'm trying to convert quote nodes into contracts, via my custom module, but I'm having problems with the node_convert API. I'm not sure what I'm doing wrong. Here's a code snippet:

<?php
if (module_exists('node_convert')) {
  node_convert_node_convert($data->nid, 'contract', array('field_node_state', 'field_products'), array('field_node_state', 'field_products'), TRUE);
}
?>

Am I supposed to include the "title" and "body" fields in the $source_fields and $dest_fields arrays, along with the "field_x" fields? The documentation says these variables should be "an array containing the source field names" and "an array containing the destination field names", but it doesn't specify whether or not "title" and "body" should be included.

Also, I'm not clear on what I'm supposed to do with the $hook_options parameter. This is optional, correct?

Thank you.

Comments

Anonymous’s picture

UPDATE: I used the exact same code snippet in a Drupal 6 module and it's working fine. So, either I'm doing something wrong in Drupal 7, or there is a bug in the 7.x branch of the Node Convert module.