Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Consolidate retrieval of searchFormValues #18591

Merged
merged 1 commit into from
Sep 25, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

[REF] Consolidate retrieval of searchFormValues

Before

Currently there are 3 ways in which the values from the searchForm are retrieved

  1. the search form sets a value 'searchFormName' on the form during search which can
    be later retrieved
  2. the search task has an action that reflects the form it came from
  3. as per 2 but there is additional handling for the fact it might be
    the contact search (knowable because the entity has been set to 'Contact'

After

$values = $form->getSearchFormValues();

used in all places - it uses method 3

Technical Details

I'm not 100% sure at this stage that the selected method (3) in this PR is the best -
but it seems 'as good' as 1 with less form-state stuff and this PR consolidates it
into 1 place so it is handled consistently

Comments

@civibot
Copy link

civibot bot commented Sep 25, 2020

(Standard links)

@civibot civibot bot added the master label Sep 25, 2020
$values = $this->controller->exportValues('Custom');
}
else {
if ($entityShortname !== 'Contact') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entityShortName will be contact if $this->get('entity') !== 'Contact'

@@ -79,6 +79,9 @@ public function getDefaultEntity() {
* @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
// SearchFormName is deprecated & to be removed - the replacement is for the task to
// call $this->form->getFormValues()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these new comment blocks have a typo. Shouldn't it be

Suggested change
// call $this->form->getFormValues()
// call $this->form->getSearchFormValues()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah - I renamed the fn - will fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw fixed

Currently there are 3 ways in which the values from the searchForm are retrieved

1) the search form sets a value 'searchFormName' on the form during search which can
be later retrieved
2) the search task has an action that reflects the form it came from
3) as per 2 but there is additional handling for the fact it might be
the contact search (knowable because the entity has been set to 'Contact'

I'm not 100% sure at this stage that the selected method (3) in this PR is the best -
but it seems 'as good' as 1 with less form-state stuff and this PR consolidates it
into 1 place so it is handled consistently
@colemanw colemanw merged commit 3b61281 into civicrm:master Sep 25, 2020
@colemanw colemanw deleted the search branch September 25, 2020 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants