From ce34ca9c1bcefd148d74eaba4f1a78a2654360ae Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 9 Dec 2013 19:02:53 -0800 Subject: [PATCH] CRM_Admin_Form_OptionValue - Set cancel behavior using cancelAction instead of JS Coleman told me to do it. --- CRM/Admin/Form/OptionValue.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Admin/Form/OptionValue.php b/CRM/Admin/Form/OptionValue.php index 917ee385a2..e168c13703 100644 --- a/CRM/Admin/Form/OptionValue.php +++ b/CRM/Admin/Form/OptionValue.php @@ -189,9 +189,8 @@ class CRM_Admin_Form_OptionValue extends CRM_Admin_Form { $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE); } + $this->add('hidden', 'gid', $this->_gid); $this->addFormRule(array('CRM_Admin_Form_OptionValue', 'formRule'), $this); - $cancelURL = CRM_Utils_System::url('civicrm/admin/optionValue', "gid={$this->_gid}&reset=1"); - $cancelURL = str_replace('&', '&', $cancelURL); $this->addButtons( array( array( @@ -202,12 +201,21 @@ class CRM_Admin_Form_OptionValue extends CRM_Admin_Form { array( 'type' => 'cancel', 'name' => ts('Cancel'), - 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"), ), ) ); } + function cancelAction() { + parent::cancelAction(); + + $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0); + $cancelURL = CRM_Utils_System::url('civicrm/admin/optionValue', "gid={$gid}&reset=1"); + + $session = CRM_Core_Session::singleton(); + $session->pushUserContext($cancelURL); + } + /** * global form rule * -- 2.25.1