[development] drupal_goto an external destination
Dave Cohen
drupal at dave-cohen.com
Tue May 6 15:35:49 UTC 2008
Thanks for your suggestion of using $form['#redirect']. That's working for
me.
I was having trouble choosing from all the options for sending the user
elsewhere after submitting a form. As I understand it, the options are...
1) set $form['#action']. Useful if you are posting the data elsewhere. In my
case this would have prevented validate and submit callbacks from being
called.
2) set $form['#redirect']. Useful if you know in advance where to send the
user after submit callbacks.
3) have your submit callback return the URL to redirect to. Useful to
dynamically determine where to go next. If multiple submit callbacks, only
one will be honored. Loses to $form['#redirect'] if both are specified.
4) set ?destination= in the URL, or $form['destination'] as a form element.
Unlike the other methods this works only with local paths. Takes priority
over options 2 and 3. This is not part of the form api, it's part of
drupal_goto().
On Tuesday 06 May 2008, Ivan Sergio Borgonovo wrote:
> On Tue, 6 May 2008 09:56:59 -0400
>
> "Moshe Weitzman" <weitzman at tejasa.com> wrote:
> > That code makes it clear that external urls are simply not
> > supported, ...
It does?
I wanted to ask here in case this was done on purpose. I.e. to prevent a
cross site scripting attack or some such.
>
> If he can avoid to use #destination, he can still redirect to external
> sites even with the a $query as I explained in the previous post.
> If he need to POST the result to an external site wouldn't specifying
> an #action work?
I don't want to post to an external site. I want to redirect there after
submit handlers have been called.
More information about the development
mailing list