Buy Now
Sign in

Start date not equaling the current date

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

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: http://www.martinaviation.info/

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

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

jQuery(document).ready(function(chronoQ){
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!

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
J
jlad00 3
October 09 2014, 22:20 #337276
Thank you for the response and solution! I appreciate it.
GreyHead 64
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.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
M
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 64
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
<?php
$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.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
J
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,

jjohall2000
admin 29
July 17 2015, 08:54 #349495
They should work fine together, does it work when you remove the custom code ?
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!