I have the following content types:
- event
- signup
I'm dealing with my_singnup module, for which I wish to:
- allow user to add signup content (same as core node/add/signup)
- using signup/event/%eventid path (it is simple link expose in every event)
- presenting (while adding) some information from event in left side and node/add/signup form on the right side
- preventing signup/event without argument to run
The code I have already wrote is the following.
function my_singnup_menu() {
$items = array();
$items['signup/event'] = array(
'title' => 'Sorry, no such event.',
'page callback' => 'There is no event id in path.',
'type' => MENU_CALLBACK,
'access callback' => TRUE // for now
);
$items['signup/event/%eventid'] = array(
'title' => 'Signing up for event',
'title callback' => 'my_signup_title',
'title arguments' => array(2),
'page callback' => 'my_singnup',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access callback' => TRUE // for now
);
return $items;
}
function my_signup_title($node) {
if ($node->type == 'event') {
drupal_set_title(t('Signing up for event '.$node->title));
}
if ($node->type <> 'event') {
drupal_set_title(t('Id in path is not event id.'));
}
return t('Signing up for event');
}
function my_signup($node = FALSE) {
if($node) {
if($node->type == 'event') {
module_load_include('inc', 'node', 'node.pages'); //Added
global $user; //Added
$new_node = new stdClass; //Added
$new_node->type = 'signup'; //Added - here was bug
$new_node->language = LANGUAGE_NONE; //localization
$new_node->user = $user->uid; //Added
$new_node->name = (isset($user->name) ? $user->name : ''); //Added
$form = drupal_get_form('signup_node_form', $new_node); //here was my big trouble
return $form;
}
}
return drupal_not_found();
}
function my_signup_theme($existing, $type, $theme, $path) {
return array(
'signup_node_form' => array(
'render element' => 'form',
'template' => 'signup-node-form',
'path' => drupal_get_path('module', 'my_signup'),
),
);
}
Right now, I see some form under event/signup/999 (thats good), but there is no custom groups and fields like in core default node/add/signup. I was so happy to see it that I forget to check it looks the same. I see only core vertical tabs such as Menu, Book, Version, Adress, Comments, and there is no custom fields and groups in it. It is strange.