Domanda

How to redirect in drupal 7 in form submission, I need to use the submitted data in next redirected page but below video_subtitle_view function is not printing anything

How do i do it

/**
 * Implements hook_menu()
 * 
 */ 
function video_subtitles_menu() {
  $items = array();
  $items['player/video_subtitle/view'] = array(
     'page callback' => 'video_subtitle_view',
     'access callback' => 'user_access',
     'access arguments' => array('administer video_subtitles status'),
  );
  return $items;
}

    function video_subtitle_view($form, &$form_state){
    //    print 'video_subtitle_view';
        print_r($form);
        print_r($form_state);
    } 

function video_upload_subtitles_form_submit($form, &$form_state) {

     $form_state['redirect'] = 'player/video_subtitle/view';
//     $form_state['redirect'] = array(
//            'player/video_subtitle/view',
//             array(
//                    'query' => array(
//                    'form' => $form,
//                    'form_state' => &$form_state,   
//                   ),
//              ),
//      );

}

function video_subtitle_view($form, &$form_state){
//    print 'video_subtitle_view';
    print_r($form);
    print_r($form_state);
}

do i need to pass the form data as parameter??

È stato utile?

Soluzione

IN DRUPAL 7 , Use it like this.

function video_subtitles_menu() {
$items = array();
$items['player/video_subtitle/view'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('video_subtitle_view_form'),
'access callback' => 'user_access',
'access arguments' => array('administer video_subtitles status'),
);
return $items;
}


function video_subtitle_view_form($form, &$form_state){
// form elements
return $form;
}


function video_subtitle_view_form_submit($form, &$form_state){

print_r($form['values']);
//use session here
$_SESSION['data']=$form['values'];
drupal_goto('whereever you want');
}

And next page retrieve data from Session

print_r($_SESSION['data']);

Hope this helps to you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top