Redirect form out of modal window after submit I have a form within a Colorbox Modal window which successfully submits using the _submit handler. I then successfully redirect the form to another page (which pre-loads a few fields on another form) using drupal_goto(). The problem I am having is that redirect stays in the Colorbox Modal window. I need to somehow close the modal window and transfer the url of the new form to the parent window. I can get this to work with a jquery function of

$(#my_form_id).submit(function (){
   parent.window.location="/user/register";
});


The problem with this issue is that the function calls when my form is submitted while disregarding anything that happens in the submission handler. So what ends up happening is I get the new page/form without the pre-loaded values until I refresh the page.

Do you have any thought or idea?
I would suggest using #ajax to submit the form and then allow the response to close the modal and go somewhere else. For example, here's a submit button that runs a function on click instead of submitting the form and reloading the page:

$form['submit'] = array(
  '#prefix' =&gt; '&lt;div id="super-cool-wrapper"&gt;&lt;/div&gt;',
  '#type' =&gt; 'button',
  '#value' =&gt; 'Submit',
  '#ajax' =&gt; array(
    'callback' =&gt; 'my_super_cool_ajax_callback',
    'wrapper' =&gt; 'super-cool-wrapper',
    'method' =&gt; 'replace',
  ),
);


And then in your callback function:

function my_super_cool_ajax_callback($form, $form_state) {
  // Do what you normally would with the form submission.
  return '&lt;script type="text/javascript"&gt;
    parent.window.location="some/where";
  &lt;/script&gt;';
}


Now you can process the form as needed and return a response that simply redirects the user.