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) »
  • Cancel and Profile/Create
Pages: [1]

Author Topic: Cancel and Profile/Create  (Read 1417 times)

ccowens

  • Guest
Cancel and Profile/Create
April 18, 2010, 07:27:52 am
On a form invoked by Profile/Create, I would like to have the cancel button send the user back to the page he/she was on previously.

In other words, if a page X contains a link to Profile/Create, I would like the Cancel button on the Profile/Create page to bring me back to X.  I assume that the way to do this is to get the URL for X into the cancel_URL field of the Profile/Create page, but I don't see where or when to do this.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Cancel and Profile/Create
April 18, 2010, 07:34:08 am

use the buildForm hook to overwrite the cancel_url hidden field and add your own specific cancel url

ensure that your cancel url is valid in case of validation form errors (in which case the refer is from the profile create page itself)

lobo


A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ccowens

  • Guest
Re: Cancel and Profile/Create
April 18, 2010, 07:46:31 am
Quote from: Donald Lobo on April 18, 2010, 07:34:08 am

use the buildForm hook to overwrite the cancel_url hidden field and add your own specific cancel url

ensure that your cancel url is valid in case of validation form errors (in which case the refer is from the profile create page itself)

lobo


So I'm thinking that reasonable behavior is:
Code: [Select]
If (I'm being invoked from the profile create page) {
    do nothing;
  } else {
    set cancel_URL to the referring page;}

Am I better off getting the page-to-which-I-want-to-return from the Refer http info or from the CiviCRM session stack?


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Cancel and Profile/Create
April 18, 2010, 09:06:14 pm

i'd use the http refer variable. a bit more reliable (or so i hope)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ccowens

  • Guest
Re: Cancel and Profile/Create
April 21, 2010, 05:28:11 pm
I ended up using the context stack, but in the course of doing so, I got curious....

Look at CRM/Core/Invoke.php around line 273.  Why is it pushing the plain 'civicrm/profile/view' onto the stack, as opposed to 'civicrm/profile/view/&gid='  etc, fleshed out with the GID, contact ID, etc.?

That doesn't look like the behavior I would want, but I don't understand the complexity of Invoke.php so I don't want to monkey with it without some adult supervision.



ccowens

  • Guest
Re: Cancel and Profile/Create
April 28, 2010, 08:01:38 am
Quote from: ccowens on April 21, 2010, 05:28:11 pm
I ended up using the context stack, but in the course of doing so, I got curious....

Look at CRM/Core/Invoke.php around line 273.  Why is it pushing the plain 'civicrm/profile/view' onto the stack, as opposed to 'civicrm/profile/view/&gid='  etc, fleshed out with the GID, contact ID, etc.?

That doesn't look like the behavior I would want, but I don't understand the complexity of Invoke.php so I don't want to monkey with it without some adult supervision.


I've been running with this modification for a while with no ill effect.  That does not, of course, constitute testing  ;D ;D

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Cancel and Profile/Create

This forum was archived on 2017-11-26.