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) »
  • Redirect after form processing
Pages: [1]

Author Topic: Redirect after form processing  (Read 945 times)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Redirect after form processing
February 21, 2014, 06:55:06 am
Hey all,

I have a custom form in my extension and I want to redirect to a certain page after a form has been processed. How do I do this?
I have the post process function in my form. Should I do the redirect here? But then I miss the postProcess hook of this form. Is that correct?

Thanks,
Jaap
Developer at Edeveloper / CiviCoop

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Redirect after form processing
February 21, 2014, 08:07:30 am
Code: [Select]
CRM_Utils_System::redirect($this->_redirectUrl), and do this at the end of your postProcess hook?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Redirect after form processing
February 21, 2014, 11:19:15 am
No do not issue the redirect directly. The form controller will take care of that, you just need to tell it where to go:
Code: [Select]
CRM_Core_Session::singleton()->pushUserContext($url);
Try asking your question on the new CiviCRM help site.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Redirect after form processing
February 27, 2014, 06:32:08 am
I have a very simple form. With one input field (name of city) when I click submit the form gets processed but no redirect the form gets back.
Developer at Edeveloper / CiviCoop

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Redirect after form processing
February 27, 2014, 06:47:43 am
I have found the solution.  I was using a button of type 'submit' instead of a type 'done'.

For everyone with the same question as me. Look in civicrm/CRM/Core/Controller.php on line 378
Code: [Select]
function addActions($uploadDirectory = NULL, $uploadNames = NULL) {
    $names = array(
      'display' => 'CRM_Core_QuickForm_Action_Display',
      'next' => 'CRM_Core_QuickForm_Action_Next',
      'back' => 'CRM_Core_QuickForm_Action_Back',
      'process' => 'CRM_Core_QuickForm_Action_Process',
      'cancel' => 'CRM_Core_QuickForm_Action_Cancel',
      'refresh' => 'CRM_Core_QuickForm_Action_Refresh',
      'reload' => 'CRM_Core_QuickForm_Action_Reload',
      'done' => 'CRM_Core_QuickForm_Action_Done',
      'jump' => 'CRM_Core_QuickForm_Action_Jump',
      'submit' => 'CRM_Core_QuickForm_Action_Submit',
    );
Developer at Edeveloper / CiviCoop

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

This forum was archived on 2017-11-26.