From 277fc9ab0d11ade0a8db292937c57fd02eac19f8 Mon Sep 17 00:00:00 2001 From: colemanw Date: Thu, 16 Nov 2023 15:31:35 -0500 Subject: [PATCH] Autocomplete - Search by id if entity has no title or label --- .../Api4/Event/Subscriber/DefaultDisplaySubscriber.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/search_kit/Civi/Api4/Event/Subscriber/DefaultDisplaySubscriber.php b/ext/search_kit/Civi/Api4/Event/Subscriber/DefaultDisplaySubscriber.php index 03649969ba..54cd5ce2cf 100644 --- a/ext/search_kit/Civi/Api4/Event/Subscriber/DefaultDisplaySubscriber.php +++ b/ext/search_kit/Civi/Api4/Event/Subscriber/DefaultDisplaySubscriber.php @@ -59,10 +59,9 @@ class DefaultDisplaySubscriber extends \Civi\Core\Service\AutoService implements throw new \CRM_Core_Exception("Entity name is required to get autocomplete default display."); } $idField = CoreUtil::getIdFieldName($entityName); - $searchFields = CoreUtil::getSearchFields($entityName); - if (!$searchFields) { - throw new \CRM_Core_Exception("Entity $entityName has no default label field."); - } + + // If there's no label field, fall back on id. That's a pretty lame autocomplete but better than nothing. + $searchFields = CoreUtil::getSearchFields($entityName) ?: [$idField]; // Default sort order $e->display['settings']['sort'] = self::getDefaultSort($entityName); -- 2.25.1