Reusing a node form in a separate page I have a module, and I want to have a page defined in hook_menu, that shows the add form for a specific content type, with some modifications to the form.

So far it's working, and even saving the new node, but only with the default values I'm setting in the code, i.e. it's not picking up anything the user types into the form. I checked and $form_state['input'] contains the inputted values, but $form_state['values'] doesn't, so the new node gets saved wrong.

Here's the relevant code:

function mymodule_menu() {
  return array(
    'admin/content/myadd/%' =&gt; array(
      'title' =&gt; 'my custom add page',
      'page callback' =&gt; 'mymodule_node_add',
      'page arguments' =&gt; array(3),
      'access callback' =&gt; TRUE,
      'type' =&gt; MENU_CALLBACK,
    ),
  );
}

function mymodule_node_add() {
  module_load_include('inc', 'node', 'node.pages');

  //I'm doing a print here instead of returning because I'm calling this page
  //in an AJAX popup, so I don't want the whole page to output, only the form.
  print render(drupal_get_form('mymodule_node_add_form'));
}

function mymodule_node_add_form($form, &amp;$form_state) {
  if (!isset($form_state['node']) {
    global $user;
    $node = (object) array(
      'uid' =&gt; $user-&gt;uid,
      'type' =&gt; 'mycontenttype',
      'language' =&gt; LANGUAGE_NONE,
    );

    //this is setting a default value
    $node-&gt;myfield = array(LANGUAGE_NONE =&gt; array(array('value' =&gt; arg(3))));

    $form_state['build_info']['args'] = array($node);

    $form = drupal_build_form('mycontenttype_node_form', $form_state);
    $form['actions']['submit']['#submit'][0] = 'mymodule_node_add_form_submit';
    //there's a lot more customization of the form here, like adding fields, etc.
  }

  return $form;
}

function mymodule_node_add_form_submit($form, &amp;$form_state) {
  //here's where $form_state['input'] is correct but $form_state['values'] isn't.

  $node = node_form_submit_build_node($form, $form_state);
  node_save($node);
  $form_state['values']['nid'] = $node-&gt;nid;
  $form_state['nid'] = $node-&gt;nid;
  $form_state['redirect'] = 'some/other/page';
}


So, am I doing something wrong here? Should I be concerned about form ids being wrong? (my form's id is mymodule_node_add_form, but the actual form might output mycontenttype_node_form), would this affect me?
function mymodule_node_add() {
 module_load_include('inc', 'node', 'node.pages');

  //I'm doing a print here instead of returning because I'm calling this page
  //in an AJAX popup, so I don't want the whole page to output, only the form.
  $form = node_add($node_type);//You need to pass content type here. THat's it.
  print render(drupal_get_form('mymodule_node_add_form'));
}