set default date on the frontend
authorKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Fri, 3 Nov 2023 18:23:24 +0000 (18:23 +0000)
committerKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Fri, 3 Nov 2023 18:23:24 +0000 (18:23 +0000)
ext/afform/core/ang/af/afField.component.js

index 60223ed607eb877a5950c4bd05b58a4bbfe9304b..c8c56c6e72148d6eb537551fcad79404be07b4ba 100644 (file)
           else if (ctrl.afFieldset.getStoredValue(ctrl.fieldName) !== undefined) {
             setValue(ctrl.afFieldset.getStoredValue(ctrl.fieldName));
           }
+          else if ('default_date_type' in ctrl.defn && ctrl.defn.default_date_type === 'now') {
+            let currentDate = new Date();
+            setValue(currentDate.toISOString().split('T')[0]);
+          }
           // Set default value based on field defn
           else if ('afform_default' in ctrl.defn) {
             setValue(ctrl.defn.afform_default);