From a1c22f90056676113922079373b963618a48b3d2 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 24 Jun 2019 11:59:18 +1200 Subject: [PATCH] dev/core#1059 Fix contribution search to work with url parameters in force mode Note this is part of the general 'convert receive_date to datepicker' work --- CRM/Contribute/Form/Search.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index 24262e41d5..d021b8157b 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -72,6 +72,9 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { /** * Processing needed for buildForm and later. + * + * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ public function preProcess() { $this->set('searchFormName', 'Search'); @@ -103,6 +106,9 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { } if ($this->_force) { + // Search field metadata is normally added in buildForm but we are bypassing that in this flow + // (I've always found the flow kinda confusing & perhaps that is the problem but this mitigates) + $this->addSearchFieldMetadata(['Contribution' => CRM_Contribute_BAO_Query::getSearchFieldMetadata()]); $this->postProcess(); $this->set('force', 0); } @@ -163,7 +169,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { CRM_Core_Error::deprecatedFunctionWarning('pass receive_date_high not end'); } $this->_defaults = parent::setDefaultValues(); - if (empty($this->_defaults['contribution_status_id'])) { + if (empty($this->_defaults['contribution_status_id']) && !$this->_force) { + // In force mode only parameters from the url will be used. When visible/ explicit this is a useful default. $this->_defaults['contribution_status_id'][1] = CRM_Core_PseudoConstant::getKey( 'CRM_Contribute_BAO_Contribution', 'contribution_status_id', @@ -406,6 +413,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { if (!$this->_force) { return; } + // Start by loading url defaults. + $this->_formValues = $this->setDefaultValues(); $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { -- 2.25.1