From 53b2809af7b667d7aa5d17b31648ff0b2332fc96 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 18 Jan 2018 11:17:56 +1300 Subject: [PATCH] CRM-21672 fix intra-rc regression, fatal when deleting participants Change-Id: Iccbd17d53f07a93c74ce46e9539d1768019a2532 --- CRM/Core/Form.php | 20 ++++++++++++++++++++ CRM/Core/Form/Search.php | 3 +++ 2 files changed, 23 insertions(+) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d6035cad3def..5cb75a5b2b08 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -2388,4 +2388,24 @@ public function getCurrency($submittedValues = array()) { return $currency; } + /** + * Is the form in view or edit mode. + * + * The 'addField' function relies on the form action being one of a set list + * of actions. Checking for these allows for an early return. + * + * @return bool + */ + function isFormInViewOrEditMode() { + return in_array($this->_action, [ + CRM_Core_Action::UPDATE, + CRM_Core_Action::ADD, + CRM_Core_Action::VIEW, + CRM_Core_Action::BROWSE, + CRM_Core_Action::BASIC, + CRM_Core_Action::ADVANCED, + CRM_Core_Action::PREVIEW, + ]); + } + } diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index dabab8620fea..3b3dcda18b6f 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -203,6 +203,9 @@ public function getDefaultContext() { * Add generic fields that specify the contact. */ protected function addContactSearchFields() { + if (!$this->isFormInViewOrEditMode()) { + return; + } $this->addSortNameField(); $this->_group = CRM_Core_PseudoConstant::nestedGroup();