I've got a form that starts a batch job. What's the right way to redirect them after it finishes? Calling drupal_goto() in my finish function?
drupal_goto('your/hookmenu/link', array('query' => array('destination', $_GET['destination'])));
-
Yeah, I know how
drupal_goto()
works I'm just curious if there's a better way, something like$form_state['redirect']
– drewish Aug 7 '12 at 14:42 -
I don't know a better one, but an alternative is
header('Location: index.php?q=node");
But I will not use it personally.$form_redirect['redirect']
will not work outside a form context. So drupal_goto is the only robust way to do it. – Minty Aug 8 '12 at 13:49
You can set 'redirect' in hook_batch_alter(). For example:
$batch['form_state']['redirect']['path'] = 'cart';
-
1Do you have a sample for how that would work? It doesn't seem like the batch is a form. – drewish Sep 14 '12 at 16:42
If you know the redirect path in the moment you start the batch, you can
batch_process('my/destination/path');
See https://api.drupal.org/api/drupal/includes!form.inc/function/batch_process/7
-
1What if we have query string as well in the path. For example my/destination/path?destination=admin/content – Sukhjinder Singh Nov 19 '15 at 7:03
-
-
-
Yes. 1) Read docs: api.drupal.org/api/drupal/includes!form.inc/function/… 2) Pay attention to
$redirect_callback
;) – Leksat Nov 19 '15 at 8:31
i'm create link to form (created by form api) that runs the batch with get-parameter "?destination=myRedirectPath".
batch lanch on function form_submit() and take info about redirect after batch from url.
without "goto".