CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Configurable form redirect
Pages: [1]

Author Topic: Configurable form redirect  (Read 1015 times)

donquixote

  • I post occasionally
  • **
  • Posts: 42
  • Karma: 3
  • CiviCRM version: none
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5.2
Configurable form redirect
April 05, 2011, 07:41:10 am
The petition form does a redirect to a hard-coded thank you page on successful submit. And not only then, there is also a method redirectIfSigned(), which kicks after validation, before any submit hooks are called.

There are two things wrong with this:
a) If the form submit happens via ajax, then we don't want a redirect via location header. (or should we?) Still, we need to tell the client about the successful form submission and the desired redirect url, ideally with a json parameter.
b) Someone might want to configure the redirect location. However, a simple url is not sufficient, because the redirect location can be different depending on the result of the form submission. By default it is just one GET parameter that is different, but who knows what someone wants to configure.

So, what I thought:
- Add a setter method to the Signature form (or to any form?) where you can inject either a redirect url or a handler that can dynamically decide where to redirect.
- Do something else on ajax requests. With the handler object this would be easily done, because it can be a special ajax handler in this case, that will remember the location until the json is built.

The handler could be injected in hook_civicrm_buildForm.

With the ajax submission there is the little problem that we don't know how the ajax submit was made. For instance, I use a drupal page callback that indirectly calls the civicrm page callback and then catches the output in various cases with output buffering, explicit exit() and register_shutdown_function(). All of this to avoid that page decorations are generated, and that a redirect is executed. In some cases it will be jsonp, in some cases json or xml.

I am still wondering if this should be generic for any form, or specific to the signature form.

Any thoughts?

jday

  • I post occasionally
  • **
  • Posts: 62
  • Karma: 6
  • CiviCRM version: 4.2
  • CMS version: 7.15
Re: Configurable form redirect
May 13, 2011, 05:44:23 am
I'm using the domain access module and my petition is on a non primary domain and unfortunately the thank you page shows a link to the petition (for sharing) using the primary domain rather than the active domain where the petition belongs.

How can I change the building of that link to use the correct domain?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Configurable form redirect

This forum was archived on 2017-11-26.