From eb4f581a3eda578aaf45f2691b9de73924117d15 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 4 Jan 2020 15:13:00 -0500 Subject: [PATCH] Fix loading fields for contact type blocks --- ext/afform/core/afform.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index 8502faeb12..ab90805ae0 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -354,13 +354,17 @@ function afform_civicrm_alterAngular($angular) { * @throws API_Exception */ function _af_fill_field_metadata($entityType, DOMElement $afField) { - $fieldName = $afField->getAttribute('name'); - $getFields = civicrm_api4($entityType, 'getFields', [ + $params = [ 'action' => 'create', - 'where' => [['name', '=', $fieldName]], + 'where' => [['name', '=', $afField->getAttribute('name')]], 'select' => ['title', 'input_type', 'input_attrs', 'options'], 'loadOptions' => TRUE, - ]); + ]; + if (in_array($entityType, CRM_Contact_BAO_ContactType::basicTypes(TRUE))) { + $params['values'] = ['contact_type' => $entityType]; + $entityType = 'Contact'; + } + $getFields = civicrm_api4($entityType, 'getFields', $params); // Merge field definition data with whatever's already in the markup $deep = ['input_attrs']; foreach ($getFields as $fieldInfo) { -- 2.25.1