From: colemanw Date: Thu, 16 Nov 2023 20:31:35 +0000 (-0500) Subject: Autocomplete - Search by id if entity has no title or label X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=277fc9ab0d11ade0a8db292937c57fd02eac19f8;p=civicrm-core.git Autocomplete - Search by id if entity has no title or label --- 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);