From: colemanw Date: Sat, 23 Sep 2023 02:39:21 +0000 (-0400) Subject: Afform - Fix display of boolean checkboxes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e7eeb6c1be96267e3bd5588e6f6d2f7f0502c015;p=civicrm-core.git Afform - Fix display of boolean checkboxes --- diff --git a/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js b/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js index a6124cde53..8772532e28 100644 --- a/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js +++ b/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js @@ -124,7 +124,7 @@ $scope.hasOptions = function() { var inputType = $scope.getProp('input_type'); - return _.contains(['CheckBox', 'Radio', 'Select'], inputType) && !(inputType === 'CheckBox' && !ctrl.getDefn().options); + return _.contains(['CheckBox', 'Radio', 'Select'], inputType) && !(inputType === 'CheckBox' && ctrl.getDefn().data_type === 'Boolean'); }; this.getOptions = function() { @@ -142,7 +142,7 @@ } return entityRefOptions; } - return ctrl.getDefn().options || ($scope.getProp('input_type') === 'CheckBox' ? null : yesNo); + return ctrl.getDefn().options || (ctrl.getDefn().data_type === 'Boolean' ? yesNo : null); }; $scope.resetOptions = function() { @@ -342,6 +342,10 @@ delete ctrl.node.defn.input_attrs.multiple; clearOut(ctrl.node, ['defn', 'input_attrs']); } + // Boolean checkbox has no options + if (val === 'CheckBox' && ctrl.getDefn().data_type === 'Boolean' && ctrl.node.defn) { + delete ctrl.node.defn.options; + } } setFieldDefn(); diff --git a/ext/afform/admin/ang/afGuiEditor/inputType/CheckBox.html b/ext/afform/admin/ang/afGuiEditor/inputType/CheckBox.html index 1e6762315d..d5d704b2a9 100644 --- a/ext/afform/admin/ang/afGuiEditor/inputType/CheckBox.html +++ b/ext/afform/admin/ang/afGuiEditor/inputType/CheckBox.html @@ -1,7 +1,7 @@ -