From: Coleman Watts Date: Wed, 27 Jan 2021 16:59:47 +0000 (-0500) Subject: Afform - Fix custom field blocks X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b1335297a59897b3f30339599158c2fa4893dbd1;p=civicrm-core.git Afform - Fix custom field blocks Ensure auto-generated custom field blocks appear in the UI and load correctly --- diff --git a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php index c0474106d6..782a5fcc71 100644 --- a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php +++ b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php @@ -51,7 +51,10 @@ class AfformAdminMeta { 'label' => $contactTypes[$entityName]['label'], ]; } - $info = ("\Civi\Api4\\{$entityName}")::getInfo(); + $info = \Civi\Api4\Entity::get(FALSE) + ->addWhere('name', '=', $entityName) + ->addSelect('title', 'icon') + ->execute()->first(); return [ 'entity' => $entityName, 'label' => $info['title'], diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Get.php b/ext/afform/core/Civi/Api4/Action/Afform/Get.php index 192c4cce31..844c9aa2b9 100644 --- a/ext/afform/core/Civi/Api4/Action/Afform/Get.php +++ b/ext/afform/core/Civi/Api4/Action/Afform/Get.php @@ -88,7 +88,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { } $customApi = CustomGroup::get() ->setCheckPermissions(FALSE) - ->setSelect(['name', 'title', 'help_pre', 'help_post']) + ->setSelect(['name', 'title', 'help_pre', 'help_post', 'extends']) ->addWhere('is_multiple', '=', 1) ->addWhere('is_active', '=', 1); if ($groupNames) { @@ -111,6 +111,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { } $item = [ 'name' => $name, + 'type' => 'block', 'requires' => [], 'title' => ts('%1 block (default)', [1 => $custom['title']]), 'description' => '', @@ -118,7 +119,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { 'is_public' => FALSE, 'permission' => 'access CiviCRM', 'join' => 'Custom_' . $custom['name'], - 'extends' => 'Contact', + 'block' => $custom['extends'], 'repeat' => TRUE, 'has_base' => TRUE, ];