From d7188a5d5d24d64b631f39d60411783302b6679d Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 8 Mar 2019 00:25:14 +1300 Subject: [PATCH] Standardise setTitle method on forms 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 | 10 +--------- CRM/Core/Form.php | 1 + CRM/Event/Form/Registration.php | 4 +--- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 821c71d2a9..f6e71a167d 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -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'); diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index a85cbb69dd..662580ee4f 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -752,6 +752,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public function setTitle($title) { $this->_title = $title; + CRM_Utils_System::setTitle($title); } /** diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index e35faa6125..c104fa1755 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -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']); -- 2.25.1