Forums

Default value for date field

2caffe 15 Jan, 2012
Hi all,
I would like to prefill a date field with current date.
Is it possible?
Thank you in advance.
GreyHead 16 Jan, 2012
Hi 2caffe,

Yes, you need to be careful about the date format you use though.

Drag a Custom Code action into the form On Load event and move it before the Show HTML action. Then add a code snippet like this to it replacing 'input_name' with the name of your input and 'Y-m-d' with the date format you need:
<?php
$form->data['input_name'] = date('Y-m-d');
?>


Bob
2caffe 22 Jan, 2012
Perfect, it works!
Thank you very much Sir.
This topic is locked and no more replies can be posted.