How can I set a default date for a datepicker?

Normally datepicker inputs are empty when the form loads, this FAQ shows you how to set a default date.
Drag a Custom Code action into the On Load event of your form and move it up before the Show HTML action. Add a code snippet like this:
<?php
if ( !isset($form->data['start_date']) || !$form->data['start_date'] ) {
  $form->data['start_date'] = date('Y-m-d');
}
?>
Replace start_date with the name of the datepicker input that you want to set and the format string with the form you have set for the datepicker.
This will set the datepicker to today's date; by changing date('Y-m-d') you can set it to any date in the past or future. Please see the PHP manual (or check on StackOverflow.com) for ways to work with dates.

Comments:

You need to login to be able to post a comment.