0
votes

I want to pre-select the time in a form field of type time. The user has this time as a default but it isnt working as I just get time set to 3.19am? The docs just say to set the date with selected but it didnt work?

Also I want to have the date limited so the user cant choose an old date (cant go backwards) and not more than 6 months in front and I am not sure how to do this as I didnt see it in the docs. The below code I got from other working versions from stackoverflow.

I tried 2 ways to set the time

http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html

echo  "<b>Change times to </b>";
echo $this->Form->input('start_time',array('type'=>'time','selected'=>'13:00:00'));
echo $this->Form->input('end_time',array('type'=>'time','selected'=>array('hour'=>'1','minute' => '30','meridian' => 'pm')));
echo $this->Form->input('lesson_date',array('type'=>'date','minYear' => date('Y'), 'maxYear' => date('Y+1')));
1

1 Answers

0
votes

First of all you should try the latest version to make sure it's not a bug or unsupported feature of an older version causing the problem. Apart from your wrong usage it's working fine for me with the current 2.5 branch.

That being said, the minute key in the selected array is expected to be named min instead of minute, and date('Y+1') won't do anything, date() is not like strtotime(), as can be seen in the examples in the docs that you've linked to, it should be date('Y') + 1.