File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments