Created
July 24, 2025 05:00
-
-
Save eileenmcnaughton/45c4095c3c2a403375617898fb7c51d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| It seems like you're asking about the **new configurable CiviCRM Autocomplete powered by Search Kit (SK)**. Here's how this feature works and how you can customize it: | |
| --- | |
| ## 🔍 What’s “configurable SK autocomplete” in CiviCRM? | |
| CiviCRM has modernized its autocomplete system using Search Kit. This means autocompletion fields (in forms, afforms, SearchKit etc.) now leverage the **SearchDisplay** functionality and return results using the **APIv4 “autocomplete” action**, displayed via a **Select2 widget** ([docs.civicrm.org][1]). | |
| --- | |
| ## ⚙️ What you can configure | |
| ### 1. **Which fields appear in autocomplete suggestions** | |
| You can control which fields are shown for each result (e.g. contact name, email, phone, city, etc.) by defining **which columns are included in your SearchDisplay**. Any field displayed in the results can also be searched. Non-displayed fields are ignored for filtering unless explicitly allowed ([docs.civicrm.org][1], [issues.civicrm.org][2]). | |
| ### 2. **Filtering rules and saved searches** | |
| Since autocomplete in SK is backed by saved searches, you can **limit options** via filters built into a SearchKit SavedSearch (e.g. only individuals in a specific group, particular event types, etc.). When using FormBuilder with SearchKit, however, note that there are some known issues where filtering wasn't honored in the autocomplete — improvements are being worked on in CiviCRM 5.60+ ([GitLab][3], [GitLab][3]). | |
| ### 3. **Advanced customization via hooks/events** | |
| Developers can further tweak behavior using SearchKit events: | |
| * Use `civi.api.prepare` to **whitelist or add filters** programmatically. | |
| * Use `civi.search.defaultDisplay` and `civi.search.autocompleteDefault` events to **alter SELECT fields, result formatting, ordering, joins, where clauses**, etc., for a specific field/form context ([docs.civicrm.org][1]). | |
| --- | |
| ## 👥 Where this applies | |
| * **Search‑Kit forms** or **Afforms** using SearchKit. | |
| * **FormBuilder-based forms** (e.g. front-end sign‑up forms) when a field is set to use a SearchKit autocomplete. | |
| * Custom **QuickForm or jQuery / Angular code** invoking `crmAutocomplete` tied to an SK search configuration ([GitLab][3], [docs.civicrm.org][1]). | |
| --- | |
| ## ✅ Example Use Cases | |
| ### • Want to show contact name + city in autocomplete? | |
| Create a saved search with the columns “display\_name” and “city”. Then add an autocomplete display tied to that search. | |
| ### • Need to restrict autocomplete to a subset (e.g. organization contacts in a “members” group)? | |
| Configure the SearchKit filters accordingly—or, if needed, add logic in `civi.api.prepare` to enforce filters. | |
| ### • Need different autocompletes on different forms? | |
| Define separate SearchKit saved searches and SearchDisplay nodes, and hook them into relevant fields (via Field Settings or API/FormBuilder configuration). | |
| --- | |
| ## 🧾 Summary Table | |
| | Feature | How to Configure | | |
| | -------------------------- | --------------------------------------------------------------- | | |
| | Fields shown (label etc.) | Via SearchDisplay column settings | | |
| | Search filters | In saved searches; or via API‑prepare hook | | |
| | Formatting & join logic | Use `civi.search.defaultDisplay` or `autocompleteDefault` hook | | |
| | Context-specific overrides | Detect by `formName` and `fieldName` metadata in hook callbacks | | |
| --- | |
| ## 🚧 Known limitations | |
| * On CiviCRM v5.60‑5.79, autocompletes in FormBuilder may ignore configured filters in SearchKit, leading to unfiltered result lists. This is being addressed in upcoming versions ([GitLab][3], [docs.civicrm.org][1]). | |
| * Older Core autocompletes (before v4 SK-based system) are deprecated and not configurable via these methods. | |
| --- | |
| ## 🧪 Final Thoughts | |
| The new SK‑based autocomplete system in CiviCRM gives you **much greater control over what gets shown and how it’s filtered**, but relies on properly defined **SearchKit SavedSearch + SearchDisplay** components. If you're comfortable building those and optionally using developer hooks, you can create highly tailored autocomplete fields. | |
| If you'd like help architecting a specific autocomplete (e.g. for “Participants filtered by event type”, or “Organizations filtered to non-spam entries”), just let me know your entity and filter requirements—I’d be happy to illustrate with saved search setups or hook snippets 😊 | |
| [1]: https://docs.civicrm.org/dev/en/latest/framework/autocomplete/?utm_source=chatgpt.com "Autocompletes - Developer Guide - CiviCRM Documentation" | |
| [2]: https://issues.civicrm.org/jira/browse/CRM-5106?utm_source=chatgpt.com "[CRM-5106] Make displayed data for autocomplete contact search widget configurable (can include email, phone, etc. in addition to contact name) - CiviCRM Issue Tracker" | |
| [3]: https://lab.civicrm.org/dev/core/-/issues/4138?utm_source=chatgpt.com "Form Builder - autocomplete input does not use configured filtering (#4138) · Issues · Development / CiviCRM Core · GitLab" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment