Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom redirection in drupal 7

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 317
    Comment on it

    Hello All,
    From the given blog below you will get to know about redirection of any form after submission or custom $form_state['redirect] in drupal 7:-

    First you need to override form_alter by usind drupal hook function hook_form_alter. To change the form_state['redirect],put this code in your hook_form_alter like this:-

    function MODULENAME_form_alter(&$form, &$form_state, $form_id){
        switch ($form_id) {
          case 'application_node_form':
              $nodeId = '';
              $nodeId = $form['nid']['#value'];
              if(empty($nodeId)){
                $form['actions']['submit']['#submit'][] = '_application_form_submit';
              }
            break;
    
          default:
            # code...
            break;
        }
    
    }

    Then write code in your form submit handler:-

    function _application_form_submit($form, &$form_state){
        $form_state['redirect'] = 'confirmation-page';
    }

    Please note: you need to use $form['actions]['submit']['#submit'][] instead of $form['#submit'].

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: