Buy Now
Sign in

Start date not equaling the current date

jlad00 , October 08 2014, 19:58
jlad00 3
October 08 2014, 19:58 #337238

I have created a form for a client's website using Chronoforms. It is great, thanks for the awesome app. There is one request from the client that I have been trying to implement without success, however. They want the date picker to only allow dates to be chosen that are more than 2 weeks in the future from the current date. I used some PHP code to accomplish this and added it to the extra parameters area of my date-picker. below is the simple code I used...

$date = date('m/d/Y h:i:s a', time());
data-start_date=<?php echo date('m-d-Y', strtotime("+14 days")); ?>

It works, however, only after first saving the form. Once the current day advances, it only blocks the next 13 days out, then 12 days, and so on. How can I get the date picker to recognize the current date and block out the next 14 days without re-saving the form? The form is current here:

I appreciate any help you can provide.
admin 33
October 09 2014, 08:38 #337245
Hi jlad,

Please try the following code inside a "load JS" action above the html action:

chronoQ("#field_id").data("start_date", "<?php echo date('m-d-Y', strtotime('+14 days')); ?>");

Please pay attention that the "field_id" needs to be replaced!

jlad00 3
October 09 2014, 22:20 #337276
Thank you for the response and solution! I appreciate it.
GreyHead 65
October 10 2014, 10:25 #337289
Hi jlad00,

Just as a footnote here it looks as if the PHP in the Extra Parameters area is only run when you save the form - so the 'start date' is fixed then. That would explain the behaviour you saw.

If you'd like to buy me a coffee or two, thank you very much
marald 10
June 12 2015, 15:20 #348223
I used the same system to advance the start date 20 days in the future, what perfectly works. But... When choosing the date picker you'll only see non selectable values because the first available date is 20 days from now. How do I set the viewing start date to let's say 15 days advance from current date? I tried default_date, view_date etc.. but nothing seems to work, the datepicker always starts on today.
GreyHead 65
June 13 2015, 10:18 #348244
Hi Marald,

This isn't perfect but may do the job. Add a Custom Code action to the form On Load event and add code like this
$form->data['start_date'] = date('d-m-Y', strtotime('+20 days'));
Replace 'start_date' with the name of your datepicker.

This will set a default value for the datepicker 20 days ahead and when clicked it will open showing that date.

If you'd like to buy me a coffee or two, thank you very much
jjohall2000 1
July 09 2015, 02:56 #349180
Hi Bob,

This worked really well for me however it does not take into account other parameters set such as data-open_days.

Is there a way to set the data-open_days using the same or similar method (even Javascript/jQuery using load JS)?

Many Thanks,

admin 33
July 17 2015, 08:54 #349495
They should work fine together, does it work when you remove the custom code ?