Add a helper function to ensure we always set the correct tab for manage events
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sat, 22 Jun 2019 11:25:04 +0000 (12:25 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sun, 23 Jun 2019 12:08:35 +0000 (13:08 +0100)
CRM/Event/Form/ManageEvent.php
CRM/Event/Form/ManageEvent/EventInfo.php
CRM/Event/Form/ManageEvent/Fee.php
CRM/Event/Form/ManageEvent/Location.php
CRM/Event/Form/ManageEvent/Registration.php
CRM/Event/Form/ManageEvent/Repeat.php
CRM/Event/Form/ManageEvent/ScheduleReminders.php
CRM/Event/Form/ManageEvent/TabHeader.php
CRM/Friend/Form/Event.php
CRM/PCP/Form/Event.php

index 9e065f4cc16612d808b96c1912248e58feae6fd9..17c9b9e78daa1be588f72450b8d9113e90649e99 100644 (file)
@@ -100,6 +100,21 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
     return 'create';
   }
 
+  /**
+   * Set the active tab
+   *
+   * @param string $default
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function setSelectedChild($default = NULL) {
+    $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $this, FALSE, $default);
+    if (!empty($selectedChild)) {
+      $this->set('selectedChild', $selectedChild);
+      $this->assign('selectedChild', $selectedChild);
+    }
+  }
+
   /**
    * Set variables up before form is built.
    */
index db2d950951b2ac5886cbf4c2570df6b160f824de..0bf756f151a2447f52591d70965e6a7d1b914a41 100644 (file)
@@ -46,7 +46,7 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent {
    */
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'settings');
+    $this->setSelectedChild('settings');
 
     $entityID = $this->_id ?: $this->_templateId;
     if ($entityID) {
index ddc1c2da065fec87d9e8aa72b922785207cd76bc..46420b809a33d9ac4eb5e017517f3a1097b3ac09 100644 (file)
@@ -62,7 +62,7 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
    */
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'fee');
+    $this->setSelectedChild('fee');
   }
 
   /**
index b33eafe0a4205523283ec64a8849b865a2b4b397..7e2c8a8889dc968e6707625c4c9c560e743dc646 100644 (file)
@@ -73,7 +73,7 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent {
    */
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'location');
+    $this->setSelectedChild('location');
 
     $this->_values = $this->get('values');
     if ($this->_id && empty($this->_values)) {
index 0c62605713f5d74781a32d6ffa6fe48deeae1e6e..0c03c4f9f963e62e776bc1d509430916c8682f52 100644 (file)
@@ -55,7 +55,7 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent
     $this->_profileBottomNumAdd = CRM_Utils_Array::value('addProfileNumAdd', $_GET, 0);
 
     parent::preProcess();
-    $this->assign('selectedChild', 'registration');
+    $this->setSelectedChild('registration');
 
     $this->assign('addProfileBottom', $this->_addProfileBottom);
     $this->assign('profileBottomNum', $this->_profileBottomNum);
index f02716591d66fde53b21c62a0f7da0a8c40e298b..9aad1cd161c099a6f28fe5c057e27c72a9578bdb 100644 (file)
@@ -26,7 +26,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
 
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'repeat');
+    $this->setSelectedChild('repeat');
     $this->assign('currentEventId', $this->_id);
 
     $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
index 483f275de624a21e197ef85cc3d4ff905cfbfbcc..4129564e57392c4f233bf6573d9afcc9c7a5b7ef 100644 (file)
@@ -47,7 +47,7 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage
    */
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'reminder');
+    $this->setSelectedChild('reminder');
     $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
 
     $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([
index c966147e4fc70a7ff684c1ef57d3d98acbd8bf40..d77440c1a06d7510ff6bc6ae435999d223433ba0 100644 (file)
@@ -45,8 +45,6 @@ class CRM_Event_Form_ManageEvent_TabHeader {
    * @throws \CRM_Core_Exception
    */
   public static function build(&$form) {
-    $form->assign('selectedChild', CRM_Utils_Request::retrieve('selectedChild', 'Alphanumeric', $form));
-
     $tabs = $form->get('tabHeader');
     if (!$tabs || empty($_GET['reset'])) {
       $tabs = self::process($form);
index bf5b6cb51828b5769d8703a026f0a936180b01cd..2e68f80dc88d9ccd6cff7fdedfb8ce3b500222c1 100644 (file)
@@ -48,7 +48,7 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent {
 
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'friend');
+    $this->setSelectedChild('friend');
   }
 
   /**
index da7802382bd5f39d92d255d89a08c4062d040820..f242036b3e04d32918513961cc795f07de5531ed 100644 (file)
@@ -48,7 +48,7 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent {
 
   public function preProcess() {
     parent::preProcess();
-    $this->assign('selectedChild', 'pcp');
+    $this->setSelectedChild('pcp');
   }
 
   /**