Start date not equaling the current date

jlad00 08 Oct, 2014
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.
Max_admin 09 Oct, 2014
Answer
1 Likes
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, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jlad00 09 Oct, 2014
Thank you for the response and solution! I appreciate it.
GreyHead 10 Oct, 2014
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
marald 12 Jun, 2015
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 13 Jun, 2015
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
jjohall2000 09 Jul, 2015
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
Max_admin 17 Jul, 2015
They should work fine together, does it work when you remove the custom code ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.