From 8cb596a50423f8c986239c30da4fff843a82a613 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 4 Jan 2021 19:18:25 -0500 Subject: [PATCH] Fix APIv3 profile.getfields to return correctly keyed phone field This fixes the phone profile field to have the correct field key to match profile forms. Fixes https://github.com/civicrm/org.civicrm.contactlayout/issues/91 --- api/v3/Profile.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/v3/Profile.php b/api/v3/Profile.php index fb0597faf5..59563c1773 100644 --- a/api/v3/Profile.php +++ b/api/v3/Profile.php @@ -632,23 +632,23 @@ function _civicrm_api3_map_profile_fields_to_entity(&$field) { $entity = 'contact'; } $entity = _civicrm_api_get_entity_name_from_camel($entity); - $locationFields = ['email' => 'email']; + $locationFields = ['email', 'phone']; $fieldName = $field['field_name']; if (!empty($field['location_type_id'])) { - if ($fieldName == 'email') { - $entity = 'email'; + if (in_array($fieldName, $locationFields)) { + $entity = $fieldName; } else { $entity = 'address'; } $fieldName .= '-' . $field['location_type_id']; } - elseif (array_key_exists($fieldName, $locationFields)) { + elseif (in_array($fieldName, $locationFields)) { + $entity = $fieldName; $fieldName .= '-Primary'; - $entity = 'email'; } if (!empty($field['phone_type_id'])) { - $fieldName .= '-' . $field['location_type_id']; + $fieldName .= '-' . $field['phone_type_id']; $entity = 'phone'; } -- 2.25.1