I insert a webform in a cck content with nodereference field.
When i submit the form with errors, it goes to the webform node, instead of show them in the cck node.

Comments

quicksketch’s picture

Status: Active » Closed (duplicate)
danielb’s picture

ehe if anyone found this issue in google trying to figure out how to put a Node Reference select into a webform - that's not what this is about. To do that here is a hint

<?php
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if (in_array($op, array('insert', 'update', 'delete')) && $node->type == 'job') {
    $extra = unserialize(db_result(db_query("SELECT extra FROM {webform_component} WHERE nid = 29 AND form_key = 'job'")));
    $result = db_query("SELECT nid,title FROM {node} WHERE type = 'job'");
    while ($row = db_fetch_array($result)) {
      $choices[] = $row['nid'].'|'.$row['title'];
    }
    if (!empty($choices)) {
      $extra['items'] = implode("\n", $choices);
    }
    db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = 29 AND form_key = 'job'", serialize($extra));
    drupal_set_message("Job choices in <a href='node/29'>careers form</a> have been updated.");
  }
}

?>

I create a select with no choices, and that code adds the node choices in when a node of that type is saved.

beauz’s picture

Would this update the form if new nodes were created? Can you give any more info on how I would go about adding this code? where exactly should it go?