Forums

Default date in Datepicker

jack19 19 Nov, 2012
Hi,
using this code as Field Default Value
<?php echo date('d-m-Y'); ?>

in a text field I get the correct date: 19-11-2012.
If I use the same code in datepicker, this code does not work and displays: 01-01-2012.
Looking at the html source code value is correct to 19-11-2012.
Any idea?
GreyHead 19 Nov, 2012
Hi jack19,

If you add a Custom Code action to the On Load event of your form and put this code in it then it seems to work OK:
<?php
$form->data['start_date'] = date('Y-m-d');
?>

I tested this here. You may need to change the input name and the format string to suit your form.

Bob
jack19 19 Nov, 2012
Hi GreyHead,
tank you for reply, but don't work.
I'm using Joomla 1.5.26 and CFV4 3.5.1
Regards.
GreyHead 26 Nov, 2012
Hi jack19,

Did you get this to work? If not please post the code and actions you have used.

Bob
elleoerre 09 Mar, 2013
Hello, I too have tried and does not work. The datapicker remains ... 01/01/2013 How can I do? This is the custom code I used:

<?php
$tempo=time();
$giorno=date('d m Y',$tempo);
echo $giorno;
$form->data['datacircolare'] = $giorno;
?>

Inside On Load I have uploaded the following actions:

Custom Datapicker
Custom Code
show HTML


HELP ME PLEASE.....!
GreyHead 09 Mar, 2013
Hi elleoerre,

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
This topic is locked and no more replies can be posted.