Flipkart

Thursday, October 28, 2010

drupal_get_form() for returning a node form

// required for Drupal 6
module_load_include('inc', 'node', 'node.pages');
// which nodeform you want
$node_type = 'YOURNODETYPE';
$form_id = $node_type . '_node_form';
// maybe add current users info
global $user;
// create a blank node

$node->uid = $user->uid;
$node->name = (isset($user->name) ? $user->name : '');
$node->type = $node_type;

// Invoke hook_nodapi and hook_node
node_object_prepare($node);
// Or you can also use an exiting node, for example
// $node = node_load(123);
// and the display the form:
$output = drupal_get_form($form_id, $node);

---------------------------------------------------------------------------------------
For User Edit Form:

include_once drupal_get_path('module', 'user') . '/user.pages.inc';
global $user;
 $output = "";
 $account = user_load($user->uid);
 $category = 'account';
//  print_r($userInfo);
 $output = drupal_get_form('user_profile_form', $account, $category);
return $output;