views:

34

answers:

3
A: 

Try

$form_state['redirect'] = "dir1/dir2/mypage";
Mike Munroe
Thanks,But i tried that.I also tried: <code> unset( $form_state['storage'] ); </code>as per pg 250 of Pro Drupal Development by John VanDyk
Paul
A: 

If you've only got one handler for your submit you could easily redirect with

function _mymodule_school_registration_submit(..args...) {
...
drupal_goto('somewhere');
}

I think the functionality is the same.

http://api.drupal.org/api/function/drupal_goto/6

I tend to avoid redirects so once you have met your deadline I would refactor your code. You can usually get away with out redirecting.

Rimian
Never use `drupal_goto` in a submit handler. Your module will not know what else implements a submit handler, and the point of the handler/hook system is to accommodate other implementations gracefully.
Mark Trapp
yes, agreed, Mark. I did resolve this issue finally with variable_set/get and some logic in the validation function. Thanks a lot for the helpful comments.
Paul
+1  A: 

Your hook_form_alter() implementation is not correct:

  • Without parameters, you're aren't modifying anything, so none of your changes get registered,
  • $form['#submit'] and $form['#validate'] are already arrays with content, so you should not be resetting them with array(),
  • unsetting $form['#action'] causes the form to do nothing when submitted,
  • setting $form['#redirect'] in hook_form_alter() will get overridden by other handlers, and
  • your hook_form_alter() implementation would affect (and break) every form.

More info: Forms API Reference

Instead, try the following:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id === 'form_id_goes_here') {
    // Code here

    $form['account']['pass'] = array(
      '#type' => 'password_confirm', 
      '#size' => 25, 
      '#description' => t(''), 
      '#required' => TRUE
    );

    unset($form['Birthdate']['profile_birthdate']);
    unset($form['Birthdate']);

    $form['#validate'][] = '_mymodule_school_registration_validate';
    $form['#submit'][] = '_mymodule_school_registration_submit';
  }
}

function _mymodule_school_registration_submit($form, &$form_state) {
  // Code here

  $form_state['redirect'] = 'dir1/dir2/mypage';
}
Mark Trapp