$controller->setDynamicAction($setDynamic);
if ($this->_force) {
-
+ $this->loadMetadata();
$this->postProcess();
/*
return ts('Search');
}
+ /**
+ * Load metadata for fields on the form.
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ protected function loadMetadata() {
+ // @todo - check what happens if the person does not have 'access civicontribute' - make sure they
+ // can't by pass acls by passing search criteria in the url.
+ $this->addSearchFieldMetadata(['Contribution' => CRM_Contribute_BAO_Query::getSearchFieldMetadata()]);
+ $this->addSearchFieldMetadata(['ContributionRecur' => CRM_Contribute_BAO_ContributionRecur::getContributionRecurSearchFieldMetadata()]);
+ }
+
}
if (!$this->_force) {
return;
}
- // Start by loading url defaults.
- $this->_formValues = $this->setDefaultValues();
$status = CRM_Utils_Request::retrieve('status', 'String');
if ($status) {
*/
public function setDefaultValues() {
$defaults = (array) $this->_formValues;
- foreach (['Contact', $this->getDefaultEntity()] as $entity) {
+ foreach (array_keys($this->getSearchFieldMetadata()) as $entity) {
$defaults = array_merge($this->getEntityDefaults($entity), $defaults);
}
return $defaults;
/**
* Set the form values based on input and preliminary processing.
+ *
+ * @throws \Exception
*/
protected function setFormValues() {
if (!empty($_POST) && !$this->_force) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
+ elseif ($this->_force) {
+ $this->_formValues = $this->setDefaultValues();
+ }
$this->convertTextStringsToUseLikeOperator();
}