Return to Snippet

Revision: 35971
at November 15, 2010 20:40 by jjensen90


Initial Code
$form_state = array();
module_load_include('inc', 'node', 'node.pages');  // new for Drupal 6
$nodeTmp = array('type' => 'order'); // a variable holding the content type

$form_state['values']['type'] = 'order'; // the type of the node to be created
$form_state['values']['status'] = 1; // set the node's status to Published, or set to 0 for unpublished
$form_state['values']['title'] = 'Some Node Title Here';   // the node's title

//$product = $order=>products;
//$variables = get_object_vars($product);
//$keys = array_keys($variables);

$form_state['values']['body'] = $order->products[0]->data['attributes'][2];

//drupal_set_message('<pre>'. print_r($order, TRUE) .'</pre>');
//drupal_set_message('<pre>'.  .'</pre>');

// the body, not required

$form_state['values']['name'] = 'jacobj'; 
$form_state['values']['op'] = t('Save');  // this seems to be a required value

  // call the function to create the node, node_revisions, and CCK values.
  // Replace "story" with the name of your form / content type
$errs = drupal_execute('order_node_form', $form_state, (object) $nodeTmp);

Initial URL


Initial Description


Initial Title
drupal ubercart create node

Initial Tags


Initial Language
PHP