0

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??

1
  • you can put form state into server session and then can use it on next page
    – arpitr
    Commented Apr 7, 2014 at 10:08

1 Answer 1

1

You can use server session to keep your form state something like below

function video_upload_subtitles_form_submit($form, &$form_state) {
    $_SESSION['my_form_data'] = $form_state;
    $form_state['redirect'] = 'player/video_subtitle/view';

}

// Then

function video_subtitle_view(){
    print_r($_SESSION['my_from_data']);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.