Skip to content

Commit

Permalink
dev/core#1059 Fix contribution search to work with url parameters in …
Browse files Browse the repository at this point in the history
…force mode

Note this is part of the general 'convert receive_date to datepicker' work
  • Loading branch information
eileenmcnaughton committed Jun 24, 2019
1 parent e8082ca commit a1c22f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CRM/Contribute/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function getDefaultEntity() {

/**
* Processing needed for buildForm and later.
*
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public function preProcess() {
$this->set('searchFormName', 'Search');
Expand Down Expand Up @@ -103,6 +106,9 @@ public function preProcess() {
}

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);
}
Expand Down Expand Up @@ -163,7 +169,8 @@ public function setDefaultValues() {
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',
Expand Down Expand Up @@ -406,6 +413,8 @@ public function fixFormValues() {
if (!$this->_force) {
return;
}
// Start by loading url defaults.
$this->_formValues = $this->setDefaultValues();

$status = CRM_Utils_Request::retrieve('status', 'String');
if ($status) {
Expand Down

0 comments on commit a1c22f9

Please sign in to comment.