You are here

function multi_node_add_frame_submit in Multi Node Add 6

Saves the node.

File

./multi_node_add.module, line 226
This module allows to create multiple nodes using one page, one form submission. Uses AJAX.

Code

function multi_node_add_frame_submit($form, &$form_state) {
  global $user;
  unset($form_state['values']['form_build_id']);
  unset($form_state['values']['form_token']);
  unset($form_state['values']['form_id']);
  unset($form_state['values']['createnodes']);
  if (!isset($form_state['values']['name'])) {
    $form_state['values']['name'] = $user->name;
  }
  $type = str_replace('-', '_', arg(2));
  $node = node_submit($form_state['values']);
  $node->type = $type;
  $node->comment = variable_get('comment_' . $type, COMMENT_NODE_READ_WRITE);
  node_save($node);
  if ($node->nid) {
    unset($form_state['rebuild']);
    $form_state['nid'] = $node->nid;
    $form_state['redirect'] = 'multi_node_add/status/' . arg(2) . '/' . $node->nid;
  }
}