Details
-
Type: Improvement
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 4.7.25
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:No
Description
This is a supplement to https://issues.civicrm.org/jira/projects/CRM/issues/CRM-20630.
Issue description:
When using Activity Search with force=1 mode we are able to pass search criteria by URL parameters.
However there is an issue with search form - some of fields values are not set to values passed by URL. It's because some fields which have their 'default value' set in CRM_Activity_BAO_Query::buildSearchForm() method override the values passed by URL.
Here are relevant steps of search flow:
1). Execute CRM_Core_Form::buildForm() method.
2). The CRM_Core_Form::buildForm() executes $form->preProcess() method (in our case it's CRM_Activity_Form_Search::preProcess()).
Here we handle URL parameters and pass them into the search values.
3). The CRM_Core_Form::buildForm() executes $form->buildQuickForm() metod (in our case it's CRM_Activity_Form_Search::buildQuickForm()).
4). The CRM_Activity_Form_Search::buildQuickForm() method executes CRM_Activity_BAO_Query::buildSearchForm() method
which sets some of the fields default values whether or not we pass the values by URL. This causes overriding of URL parameters with setDefaults() calls made inside CRM_Activity_BAO_Query::buildSearchForm().
5). The CRM_Core_Form::buildForm() executes checking defaults by calling $form->setDefaultValues() (in our case it's CRM_Activity_Form_Search::setDefaultValues()).
6). If setDefaultValues() method returns an array then it's used to set the form values to the array.
So here we are able to re-set the form values in case they were overriden in step 4).
In CRM_Activity_Form_Search there is no setDefaultValues() implementation so the parent implementation is called which always return NULL.
Solution:
Implement setDefaultValues() methods into CRM_Activity_Form_Search class (originally it's not implemented) and handle defaults resetting if force=1 is used for the search.