Code in manomodule.module file
/* Error handling */
error_reporting(E_ALL);
ini_set("display_errors","On");
/**
*
* Implementation of menu hook
*/
function manomodule_menu() {
$items = array();
$items['test_form'] = array(
'title' => t('Test form'),
'page callback' => 'get_products',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
*
* Implementation of theme hook
*/
function manomodule_theme() {
return array(
'page_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'product-list',
),
);
}
function get_products() {
/* Create a new node and form creation */
$node = new stdClass();
$node->type = 'page';
module_load_include('inc', 'node', 'node.pages');
$form_arr = drupal_get_form('page_node_form',$node);
return $form_arr;
}
/**
*
* Implementation of form alter hook
*/
function manomodule_form_alter(&$form, &$form_state, $form_id) {
/* Theme alter based on form id */
if ($form_id == 'page_node_form') {
$form['#theme'] = 'page_node_form';
}
}
/**
*
* Implementation of node related process hook
*/
function manomodule_nodeapi(&$node, $op) {
if ($node->type == 'page') {
switch ($op) {
case 'insert':
$_SESSION['fromform'] = 'product';
break;
case 'view':
// redirect to thank you page when submit
// and workflow process done.
$fromform = $_SESSION['fromform'];
unset($_SESSION['fromform']);
if ($fromform == 'product') {
drupal_goto('admin/content/node');
}
break;
}
}
}
Code in product-list.tpl.php
print drupal_render($form['title']);
print drupal_render($form['body_field']['body']);
print drupal_render($form['form_id']);
print drupal_render($form['form_build_id']);
print drupal_render($form['form_token']);
print drupal_render($form['buttons']['submit']);
/* print drupal_render($form); */
No comments:
Post a Comment