Afform: Only permit Date fields to be made into a select list if it is a search form
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 24 Feb 2021 09:40:09 +0000 (20:40 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 24 Feb 2021 09:40:09 +0000 (20:40 +1100)
ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js

index 950722e4952293b8ef7e802680ae5d69b45c2b48..c2215bee5ede538bffe4c2f08e8a6b40cc867876 100644 (file)
         $scope.meta = afGui.meta;
       };
 
+      this.isSearch = function() {
+        return !_.isEmpty($scope.meta.searchDisplays);
+      };
+
       // Returns the original field definition from metadata
       this.getDefn = function() {
         var defn = afGui.getField(ctrl.container.getFieldEntityType(ctrl.node.name), ctrl.node.name);
@@ -75,7 +79,7 @@
             return defn.options || defn.data_type === 'Boolean';
 
           case 'Select':
-            return defn.options || defn.data_type === 'Boolean' || defn.input_type === 'Date';
+            return defn.options || defn.data_type === 'Boolean' || (defn.input_type === 'Date' && ctrl.isSearch());
 
           case 'Date':
             return defn.input_type === 'Date';