CRM-21672 fix intra-rc regression, fatal when deleting participants
authoreileen <emcnaughton@wikimedia.org>
Wed, 17 Jan 2018 22:17:56 +0000 (11:17 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 17 Jan 2018 22:23:53 +0000 (11:23 +1300)
Change-Id: Iccbd17d53f07a93c74ce46e9539d1768019a2532

CRM/Core/Form.php
CRM/Core/Form/Search.php

index d6035cad3defc08a1c232c86cfdc9c652b47cb12..6303dc5e3aebe9bb98313526cf1ce4c4b3400c56 100644 (file)
@@ -2388,4 +2388,24 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
     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
+   */
+  protected 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,
+    ]);
+  }
+
 }
index dabab8620fea49eee3536dcd815b070033bf7e74..3b3dcda18b6f8d32856cada1508c8b78d3796317 100644 (file)
@@ -203,6 +203,9 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
    * Add generic fields that specify the contact.
    */
   protected function addContactSearchFields() {
+    if (!$this->isFormInViewOrEditMode()) {
+      return;
+    }
     $this->addSortNameField();
 
     $this->_group = CRM_Core_PseudoConstant::nestedGroup();