Automagically generated date/time input fields normally default to the current date and time. For a couple of reasons, I had to change this to another default value. For example's sake, let's say I needed a time field to always select 1:30 pm in an add action.
Run of the mill example:
<?php
echo $form->input('start_dt');
?>
This will output 3 select boxes; one for hours, minutes, and the merdian (am/pm) with the current time pre-selected. So if it was 3:04 pm, that would be selected.
So lets change this so that 1:30 pm is always pre-selected:
<?php
echo $form->input('start_dt', array('selected' => array('hour' => '1',
'minute' => '30',
'meridian' => 'pm')
)
);
?>
That's all there is to it! Cake's automagic owns. Hope this helps someone else :)



Comments
Josh on (12.16.16 8:35 pm) says
Søren on (2.4.04 6:49 pm) says