I have constructed a content type, 3 fields are timestamps.
I wish to reuse this content type (form input etc) to a client facing application, with the caveat being the form is modified. For example my module should be able to tweak the form (ie: Hiding the timestamps fields and updating them accordingly).
I don't want to rebuild the whole form and muck with the CCK API to get data to persist, so I am wondering if it is possible to simply re-call that form and it's functionality and tweak it ever so slightly???
I found this googleing:
//Showing a node edit page with drupal_get_form() and hook_menu()
And implemented some of it:
function _tasks_create() {
module_load_include('inc', 'node', 'node.task');
$nid = '1';
$node = node_load($nid);
return drupal_get_form('task_node_form', $node);
}
function tasks_menu() {
$items = array();
$items['tasks/create'] = array (
'type' => MENU_CALLBACK,
'title' => t('Create New Task'),
'page callback' => '_tasks_create',
// Where is $node coming from???
'page arguments' => array('task_node_form', $node),
'access arguments' => array('create tasks')
);
return $items;
}
But I see two immediate issues:
- $node in hook_menu is undefined -- where do I get it from??
- I have no idea what the $nid (Node ID) will ever be for my content type
I need to essentially re-display the form that I use in the admin, hiding everything but maybe three fields (that means no URI, menu options, etc).
I will probably need to hook into the submission of the form in this context only and update the timestamps accordingly.
What am I missing or doing wrong? Any ideas?
Alex
drupal_get_form('node_form', $node);
in your callback function? BTW there's no node.task.inc file so you can remove themodule_load_include
line. You'll probably need to replace it with an include of node.pages.inc, where that form function lives$node = new stdClass(); $node->type = 'task'; node_object_prepare($node);
would suffice before passing it todrupal_get_form()