Dynamic option lists for select elements
authorColeman Watts <coleman@civicrm.org>
Mon, 4 Nov 2019 13:02:23 +0000 (08:02 -0500)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:20 +0000 (19:13 -0700)
This should respond better to changes in the model.

ext/afform/core/ang/afField/afField.js
ext/afform/core/ang/afField/widgets/Select.html

index 6c70a98e700f0b962fba9a5f1ee2a593cb7b67c3..bd30e103d8f30452f7a731f1e6e8a30a18e7e428 100644 (file)
         $scope.getData = $scope.afFieldset.getData;
 
         $scope.getOptions = function() {
-          return _.transform($scope.defn.options, function(result, val, key) {
-            result.push({id: key, text: val});
-          }, []);
+          return {
+            results: _.transform($scope.defn.options, function(result, val, key) {
+              result.push({id: key, text: val});
+            }, [])
+          };
         };
 
         $el.addClass('af-field-type-' + _.kebabCase($scope.defn.input_type));
index e59b2c724e892df0500142da422ebd3e2cb519d4..01ae74fbe8b613ff27d3938378557439924c97e3 100644 (file)
@@ -1 +1 @@
-<input crm-ui-select="{data: getOptions(), multiple: defn.input_attrs.multiple}" id="{{ fieldId }}" ng-model="getData()[fieldName]" />
+<input crm-ui-select="{data: getOptions, multiple: defn.input_attrs.multiple}" id="{{ fieldId }}" ng-model="getData()[fieldName]" />