Skip to content

Commit 8f8a375

Browse files
committed
gpld-populate-new-minimum-date-into-linked-date-field.js: Fixed an issue with default value of field notgetting used to apply minimum date.
1 parent cf4a86e commit 8f8a375

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

gp-limit-dates/gpld-populate-new-minimum-date-into-linked-date-field.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
* 1. Install this snippet with our free Custom JavaScript plugin.
1111
* https://gravitywiz.com/gravity-forms-code-chest/
1212
*/
13-
gform.addAction( 'gpld_after_set_min_date', function( $input, date ) {
14-
$input.datepicker( 'setDate', date );
13+
const sourceFieldId = 25; // Replace with the ID of the source field (Field A)
14+
document.addEventListener( 'gform/post_render', ( event ) => {
15+
const $field = jQuery( `#input_GFFORMID_${sourceFieldId}` );
16+
const value = $field.val();
17+
if ( value ) {
18+
requestAnimationFrame( function(){
19+
$field.trigger( 'input' ).trigger( 'change' );
20+
});
21+
}
22+
});
23+
24+
gform.addAction( 'gpld_after_set_min_date', function( $input, date ) {
25+
$input.datepicker( 'setDate', date );
1526
} );

0 commit comments

Comments
 (0)