I am really stuck on this and haven't been able to find a solution. In my use-case, user must confirm his/her post when he/she submits a node form. I would like to load the server-side confirmation form as a html popup.
<?php
MY_MODULE_menu() {
$items['MY_MODULE/create'] = array(
'access callback' => TRUE,
'page callback' => 'MY_MODULE_load_form_callback',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
);
return $items
}
function MY_MODULE_load_form_callback($type) {
if($type == 'ajax') {
module_load_include('inc', 'node', 'node.pages');
global $user;
$type = 'MY_CUSTOM_NODE_TYPE';
$node = (object) array(
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => $type,
'language' => LANGUAGE_NONE,
);
node_object_prepare($node);
$form = drupal_get_form($type . '_node_form', $node);
$commands = array();
$commands[] = ajax_command_html('#form-area-wrapper', render($form));
$page = array(
'#type' => 'ajax',
'#commands' => $commands,
);
ajax_deliver($page);
}
}
function MY_MODULE_form_MY_CUSTOM_NODE_TYPE_node_form_alter(&$form, &$form_state, $form_id) {
form_load_include($form_state, 'inc', 'node', 'node.pages');