Skip to content

Commit 22afa17

Browse files
Merge pull request #714 from Fliplet/release/PS-72
https://weboo.atlassian.net/browse/PS-72
2 parents 2c3c850 + b4dd40d commit 22afa17

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

js/components/date.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ Fliplet.FormBuilder.field('date', {
7474
},
7575
watch: {
7676
value: function(val) {
77-
if (val === '' && ['default', 'always'].indexOf(this.autofill) > -1 && (this.required || this.autofill === 'always')) {
78-
this.value = this.today;
77+
if (val === '' && ['default', 'always'].indexOf(this.autofill) > -1) {
78+
if (!this.empty && (this.required || this.autofill === 'always')) {
79+
this.value = this.today;
80+
}
7981

8082
return;
8183
}
@@ -113,12 +115,18 @@ Fliplet.FormBuilder.field('date', {
113115
});
114116

115117
this.datePicker.change(function(value) {
118+
$vm.empty = false;
116119
$vm.value = value;
117120
$vm.updateValue();
118121
});
119122
},
120123
onBeforeSubmit: function(data) {
121-
// Empty date fields are validated to null before this hook is called
124+
if (this.autofill === 'default' && !this.empty && this.value) {
125+
data[this.name] = this.value;
126+
127+
return;
128+
}
129+
122130
if (this.autofill === 'always' && data[this.name] === null) {
123131
data[this.name] = this.defaultSource === 'submission' ? moment().locale('en').format('YYYY-MM-DD') : this.today;
124132
}

0 commit comments

Comments
 (0)