Afform - Use correct contact type when loading field options
authorColeman Watts <coleman@civicrm.org>
Mon, 2 Aug 2021 18:29:10 +0000 (14:29 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 2 Aug 2021 18:29:10 +0000 (14:29 -0400)
Fixes dev/core#2702

ext/afform/admin/ang/afGuiEditor/afGuiEntity.component.js
ext/afform/admin/ang/afGuiEditor/afGuiEntity.html

index 8a806cfd44e9b34c3a6ddfd0f6c2d0d23e2750f4..6786029542b0d100031e72e5a6e340fc5b116a11 100644 (file)
       $scope.elementList = [];
       $scope.elementTitles = [];
 
-      function getEntityType() {
+      this.getEntityType = function() {
         return (ctrl.entity.type === 'Contact' && ctrl.entity.data) ? ctrl.entity.data.contact_type || 'Contact' : ctrl.entity.type;
-      }
+      };
 
       $scope.getMeta = function() {
-        return afGui.meta.entities[getEntityType()];
+        return afGui.meta.entities[ctrl.getEntityType()];
       };
 
       $scope.getAdminTpl = function() {
@@ -54,7 +54,7 @@
         $scope.fieldList.length = 0;
         $scope.fieldList.push({
           entityName: ctrl.entity.name,
-          entityType: getEntityType(),
+          entityType: ctrl.getEntityType(),
           label: ts('%1 Fields', {1: $scope.getMeta().label}),
           fields: filterFields($scope.getMeta().fields)
         });
index 57f26202cfbf09bf5c52e1a9989579178fd9dcc5..a92c376322a7bb5f163b454530ae23fea291853a 100644 (file)
@@ -3,7 +3,7 @@
     <legend>{{:: ts('Values:') }}</legend>
     <div class="form-inline" ng-if="getMeta().fields[fieldName]" ng-repeat="(fieldName, value) in $ctrl.entity.data">
       <label>{{ getMeta().fields[fieldName].label }}:</label><br />
-      <input class="form-control" af-gui-field-value="getField($ctrl.entity.type, fieldName)" ng-model="$ctrl.entity.data[fieldName]" />
+      <input class="form-control" af-gui-field-value="getField($ctrl.getEntityType(), fieldName)" ng-model="$ctrl.entity.data[fieldName]" />
       <a href ng-click="removeValue($ctrl.entity, fieldName)">
         <i class="crm-i fa-times"></i>
       </a>