user1406716
user1406716

Reputation: 9705

how to embed node add form in a block?

How to embed node add form in a block?

I have tried the following but it does not work. "free_listing2_node_form" is the form_id of the node add form I want to embed in this block.

If the approach below is right, I suspect problem in this statement

$block['content'] = drupal_get_form('free_listing2_node_form');

Any help / direction is much appreciated!

<?php


function freelisting2_block_info() {
  $blocks['neil_recent'] = array(
    'info' => t('neil_Recent content'),
  );

  return $blocks;
}

function freelisting2_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'neil_recent':
      if (user_access('access content')) {
        $block['subject'] = t('Recent content');
        $block['content'] = drupal_get_form('free_listing2_node_form');
      }
      break;
  }
  return $block;
}


?>

(I am using Drupal 7)

Upvotes: 1

Views: 916

Answers (1)

kkatusic
kkatusic

Reputation: 94

Try to use this:

$block['content'] = render(drupal_get_form('free_listing2_node_form'));

I didn't test it.

Upvotes: 1

Related Questions