Q:

CakePHP Default values for date select

I have a set of selects for a date of birth:
<? php echo $this->Form->input('Profile.dob', array('label' => 'Date of Birth'
                                    , 'dateFormat' => 'DMY'
                                    , 'minYear' => date('Y') - 100
                                    , 'maxYear' => date('Y') - 13)); ? >

and want to set the defaults to be the words "DAY MONTH YEAR" in the selects. 
I have managed to do this with the gender with:
<? php echo $this->Form->input('Profile.gender', array('label' => 'Gender', 'type' => 'select',
         'options' => array('Male'=>'Male','Female'=>'Female'),'empty'=>'Select Sex')); ? >

but I don't see how to do this with the automagic date input...
Can anyone help?  Thanks

A:

Simply add:
'selected'=>date('Y-m-d')
to your array of options. 
That example will show the current date.  If you need to have a static date, replace it as required.  eg:
'selected'=>'2011-12-10'
Obviously for the date and time, use:
'selected'=>date('Y-m-d H:i:s')
or
'selected'=>'2011-12-10 11:13:45'

A:

This way works:
<? php 
echo $this->Form->input(
    'Profile.dob', 
    array(
        'label'         => 'Date of Birth',
        'dateFormat'    => 'DMY',
        'minYear'       => date('Y') - 100,
        'maxYear'       => date('Y') - 13,
        'empty'         => array(
            'day'       => 'DAY',
            'month'     => 'MONTH',
            'year'      => 'YEAR'
            )
        )
    ); 
? >

A:

If you don't mind 2 more lines, you can try doing this? 
<? php
echo $this->Form->year('Profile.dob', date('Y') - 100, date('Y') - 13, array('empty' => "YEAR"));
echo $this->Form->month('Profile.dob', array('empty' => "MONTH"));
echo $this->Form->day('Profile.dob', array('empty' => 'DAY'));

? >

