From: Coleman Watts Date: Sat, 4 Jan 2020 20:13:00 +0000 (-0500) Subject: Fix loading fields for contact type blocks X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eb4f581a3eda578aaf45f2691b9de73924117d15;p=civicrm-core.git Fix loading fields for contact type blocks --- 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) {