Standardise setTitle method on forms
authoreileen <emcnaughton@wikimedia.org>
Thu, 7 Mar 2019 11:25:14 +0000 (00:25 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 11 Mar 2019 20:45:51 +0000 (09:45 +1300)
We have inconsistent methodology for setting the title. This is a minor simplification and
consistency improvement. It also means hooks can call 'getTitle' - ideally all forms would call thi
s & title handling would be consistent.... one day

CRM/Contribute/Form/ContributionBase.php
CRM/Core/Form.php
CRM/Event/Form/Registration.php

index 821c71d2a9b35e60132a4698e2ee563e7d5f257d..f6e71a167d9ab07109f53a27c75cb5e881977f6d 100644 (file)
@@ -472,15 +472,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
       CRM_Utils_Array::value('cancelSubscriptionUrl', $this->_values)
     );
 
-    // assigning title to template in case someone wants to use it, also setting CMS page title
-    if ($this->_pcpId) {
-      $this->assign('title', $this->_pcpInfo['title']);
-      CRM_Utils_System::setTitle($this->_pcpInfo['title']);
-    }
-    else {
-      $this->assign('title', $this->_values['title']);
-      CRM_Utils_System::setTitle($this->_values['title']);
-    }
+    $this->setTitle(($this->_pcpId ? $this->_pcpInfo['title'] : $this->_values['title']));
     $this->_defaults = array();
 
     $this->_amount = $this->get('amount');
index a85cbb69dddb4c50fd9143e4154f78622cc8483b..662580ee4f107497b004801617f2197a4e27e902 100644 (file)
@@ -752,6 +752,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    */
   public function setTitle($title) {
     $this->_title = $title;
+    CRM_Utils_System::setTitle($title);
   }
 
   /**
index e35faa61252c228f489e64f35460496186fac8fd..c104fa17555d6b9fd8833abcb108215517d43b91 100644 (file)
@@ -391,9 +391,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
 
-    // setting CMS page title
-    CRM_Utils_System::setTitle($this->_values['event']['title']);
-    $this->assign('title', $this->_values['event']['title']);
+    $this->setTitle($this->_values['event']['title']);
 
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);