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

core#1805: Autocomplete-select custom field is not searchable #17569

Merged
merged 2 commits into from
Jul 14, 2020

Conversation

monishdeb
Copy link
Member

Overview

Steps to replicate:

  1. Create an 'Autocomplete Select' custom field for any component, say Contribution here
  2. Update/add two or more records with these custom field options
  3. Go to the desired search form, here 'Find Contribution'
  4. Select two or more option and submit the criteria

Before

before

After

after

Technical Details

This patch introduces two improvement and the fix for the current issue, depends on it:

  1. I have moved the CRM_Core_BAO_CustomValue::fixCustomFieldValue inside CRM_Contact_BAO_Query::convertFormValues(...) and its safe for two reason:
  • This latter fn is been accessed by both API and Search Forms to format the parameters in query format. For customfields, when it is used in API parameter, its already in OK (Operator in Key) format thus the CRM_Core_BAO_CustomValue::fixCustomFieldValue fn bypass for value for formatting in here
  • As you can see in the patch, fixCustomFieldValue fn is executed separately on all Search forms in order to format the customfield's value. The reason, why I have moved the fn and won't cause any unintended regression. In addition it gives more authority to CRM_Contact_BAO_Query::convertFormValues to now format the customfield filters too.
  1. Added form validation to prevent entering comma value in custom field form.

Comments

ping @eileenmcnaughton @seamuslee001 @JoeMurray @lcdservices

@civibot
Copy link

civibot bot commented Jun 10, 2020

(Standard links)

@civibot civibot bot added the master label Jun 10, 2020
@eileenmcnaughton
Copy link
Contributor

I think this looks OK if an r-run passes - one thing to check is that a smart group based on this reloads OK

@monishdeb
Copy link
Member Author

Thanks for pointing that out. I will mention the test result shortly with smart group.

@@ -748,6 +748,10 @@ public static function formRule($fields, $files, $self) {
$errors['option_value[' . $nextIndex . ']'] = ts('Duplicate Option values');
$_flagOption = 1;
}
if (strpos($fields['option_value'][$start], ',') != FALSE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me wonder if we need to have a status check or something as well alerting if people have any already

Copy link
Member Author

@monishdeb monishdeb Jun 10, 2020

Choose a reason for hiding this comment

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

For existing optionValue's value, with comma will won't work for 'Autocomplete Select' custom field as a filter, but doesn't affect another widget type (as a filter) like checkbox. But yeah it would be nice to inform user about this change, on status page, something like 'Use of "," is no longer supported in optionvalue for mult-select custom fields esp. for 'Autocomplete Select' widget'


$customField = $this->customFieldCreate($fields);

$custom = 'custom_' . $customField['id'];
$params = [
'email' => 'abc@webaccess.co.in',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove webaccess as historical cruft and update this to 'test@example.com'

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@monishdeb
Copy link
Member Author

jenkins test this please

@lcdservices
Copy link
Contributor

Tested and this works as expected.
Also tested and confirmed when creating a smart group based on the custom field's criteria.

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

This was only pending r-run so MOP now @lcdservices has done so

@eileenmcnaughton
Copy link
Contributor

unrelated fail

@eileenmcnaughton eileenmcnaughton merged commit caec1f1 into civicrm:master Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants