webform_civicrm icon indicating copy to clipboard operation
webform_civicrm copied to clipboard

Don't search related tables when filtering a contact reference field.

Open jmcclelland opened this issue 9 months ago • 3 comments

Overview

If you have an "Existing Contact" field, and, in the Builder tab, in the field definition's "Form display" section you configure the "Contact Display Fields" to display the State/Province, you will not get accurate results when entering a string to filter the results by. The field will display all results.

The problem is that the code builds the WHERE clause using every field entered as a display field. However, perhaps because the contact tables are LEFT JOIN'ed and the WHERE clause is an OR clause, the query somehow fails to filter the given string at all.

Since it's unlikely and even unexpected to have your search term applied to the address, email or phone tables, this patch simply removes that clause.

Before

Contact reference fields that include the "State/Province" as a display field fail to filter properly.

After

Contact reference fields, regardless of the display fields configured, are properly filtered.

jmcclelland avatar May 24 '24 20:05 jmcclelland