From e7eeb6c1be96267e3bd5588e6f6d2f7f0502c015 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 22 Sep 2023 22:39:21 -0400 Subject: [PATCH] Afform - Fix display of boolean checkboxes --- .../ang/afGuiEditor/elements/afGuiField.component.js | 8 ++++++-- ext/afform/admin/ang/afGuiEditor/inputType/CheckBox.html | 4 ++-- ext/afform/core/Civi/Afform/AfformMetadataInjector.php | 5 +++++ ext/afform/core/ang/af/afField.component.js | 7 ++++++- 4 files changed, 19 insertions(+), 5 deletions(-) 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 @@ -