Code to add node add form to a custom block (not working) I am trying to use code below to display node add form for a custom content type in a custom block.

Any guidance on why the code below may not be working is sincerely appreciated.

function stories_block_info(){
  $blocks['post_story'] = array(
    'info' =&gt; t('Post a Story - Neil Block'), 
    'cache' =&gt; DRUPAL_NO_CACHE,
  );

  return $blocks;
}

function stories_block_view($delta = ''){
  switch ($delta) {
    case 'post_story':
      $block['content'] = drupal_get_form(stories_node_form);
      // $block['content'] = block_contents($delta);
      break;
  }

  return $block;
}
For people still having trouble with the above code when using anything AJAX-related (e.g. 500 errors) or simply trying to open up the 'blocks' tab in Panels without some error (e.g. some Entity Translation functions) you might want to try the following module code instead in Drupal 7 (but some parameters may still need to be added for your purposes).

function custom_example_block_info() {

    $blocks['example_node_form'] = array(
       'info' =&gt; t('What an example'), 
    );
    return $blocks; 


}

function custom_example_block_view($delta = ''){

    $block = array();

    switch ($delta) {
        case 'example_node_form':
            global $user;
                        //Note: 'type' is your node content type and 'language' must be included
            $node = (object) array('uid' =&gt; $user-&gt;uid, 'name' =&gt; (isset($user-&gt;name) ? $user-&gt;name : ''), 'type' =&gt; 'example', 'language' =&gt; LANGUAGE_NONE);

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

            form_load_include($form_state, 'inc', 'node', 'node.pages');
            $block['content'] = drupal_build_form('example_node_form', $form_state);

            break;
    }
return $block; 

}


The important difference is that drupal_get_form cannot load the $form_state so we use function form_load_include(&amp;$form_state, $type, $module, $name = NULL) to ensure the include file is loaded whenever the form is processed and function drupal_build_form($form_id, &amp;$form_state) instead of drupal_get_form to pass $form_state. The lines above create the $form_state.