Gravity Forms Date Push Reservations

207 views Asked by At

I currently use GF for reservations 'Arrive' and 'Departure'. I would like the date displayed on the 'Departure' to always be one date ahead of the 'Arrival' date, regards of what date the guest picks. Then can pick a custom 'Departure' date, but as a default I'd like to show one date forward of the 'Arrival' date no matter what 'Arrival' date they choose.

1

There are 1 answers

0
Dave from Gravity Wiz On

This is possible with the gform_datepicker_options_pre_init JS filter. Example #3 is what you're after:

gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    if ( formId == 12 && fieldId == 8 ) {
        optionsObj.minDate = 0;
        optionsObj.onClose = function (dateText, inst) {
            jQuery('#input_12_9').datepicker('option', 'minDate', dateText).datepicker('setDate', dateText);
        };
    }
    return optionsObj;
});

If you're looking for a code-less solution, I've written a plugin that let's you do this in just a few clicks called GP Limit Dates.

Also, here is an article that addresses your specific need: How to restrict dates in second date field based on date selected in first date field with Gravity Forms