I am using the custom module to create a block wich contains a form. I added this form in a node of a custom content type. When I click to submit, I want to open a view wich contains another form and I will create it in the same module.
this is my code
function my_module_block_info() {
$blocks['visit'] = array(
'info' => t('Visit'),
'cache' => DRUPAL_CACHE_GLOBAL
);
return $blocks;
}
function my_module_block_view($delta = '') {
$block = array();
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
$nid = arg(1);
}
switch ($delta) {
case 'visit':
$block['content'] = drupal_get_form('visit_project', $nid);
break;
}
return $block;
}
function visit_project($form, &$form_state, $nid) {
$form['id'] = array(
'#type' => 'hidden',
'#value' => $nid,
);
$form['actions'] = array('#type' => 'actions');
$form['actions'] = array(
'#type' => 'submit',
'#value' => t('Visit'),
'#attributes' => array('class' => array('general_button')),
'#submit' => array('_visit_project_details')
);
return $form;
}
function my_module_menu() {
$items['my-page'] = array(
'title' => 'Title of my page',
'page callback' => 'project_details',
'access callback' => TRUE,
);
return $items;
}
function _visit_project_details($form_state)
{
$form_state['redirect'] = 'my-page';
}
function project_details() {
return '<p>ok in details of '.$_POST['id'].'</p>';
}
Can you help to go to my-page after submit form and still reading the $_POST?
Thank you