I need one button at the end of one content type view form. This button should redirect the user to another page.
I have something like the following code:
function mymodule_node_view($node, $view_mode, $langcode) {
if ($node->type == 'my_type') {
$form = drupal_get_form('redirect_button_form');
$node->content['redirect_button'] = $form;
//$node->nid is the data I need in the submit function
}
}
function redirect_button_form($form, &$form_submit) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Redirect button text'),
);
return $form;
}
function redirect_button_form_submit($form, &$form_state) {
$path = 'mypath';
$options = ****I need the nid here;
drupal_goto($path,$options );
}
How can I pass the nid from the hook_node_view to the submit function?