Afform - Fix setting default value
authorColeman Watts <coleman@civicrm.org>
Mon, 23 Aug 2021 20:21:41 +0000 (16:21 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 23 Aug 2021 20:21:41 +0000 (16:21 -0400)
String comparison was failing for integer keys.

ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js
ext/afform/admin/ang/afGuiEditor/inputType/Select.html

index b20511ae612bf2d0a6594d1e23a7be4eb1fdf61d..2cc5e04a7d843e8c62a48f7f663902e544b51e36 100644 (file)
       };
 
       $scope.defaultValueContains = function(val) {
+        val = '' + val;
         var defaultVal = getSet('afform_default');
         return defaultVal === val || (_.isArray(defaultVal) && _.includes(defaultVal, val));
       };
 
       $scope.toggleDefaultValueItem = function(val) {
+        val = '' + val;
         if (defaultValueShouldBeArray()) {
           if (!_.isArray(getSet('afform_default'))) {
             ctrl.node.defn.afform_default = [];
index 33dd6f932bbbb060cb61f1d82ca3d36ac925bdda..1f5e849f20a8f1b158335eb1c254be412570ca72 100644 (file)
@@ -6,6 +6,9 @@
       <div class="input-group-btn" af-gui-menu>
         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="crm-i fa-caret-down"></i></button>
         <ul class="dropdown-menu" ng-if="menu.open" title="{{:: ts('Set default value') }}">
+          <li class="disabled">
+            <a><strong>{{:: ts('Default Value:') }}</strong></a>
+          </li>
           <li ng-repeat="opt in $ctrl.getOptions()" >
             <a href ng-click="toggleDefaultValueItem(opt.id); $event.stopPropagation(); $event.target.blur();">
               <i class="crm-i fa-{{defaultValueContains(opt.id) ? 'check-' : ''}}circle-o"></i>