views:

500

answers:

1

hi all,

I am wondering if there is a way to specify the date format in the forms created using CakePHP's $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() that will create the whole form fields automagically.

Any input will be appreciated. Thanks.

+2  A: 

You can pass the usual options into $form->inputs that you would pass into $form->input.

For example, if you want to customise field2 below, you make the field name the key and the options array the value:

echo $form->inputs(array(
    'field1',
    'field2' => array(
        'label' => 'Date and time',
        'type' => 'datetime',
        'dateFormat' => 'DMY',
        'minYear' => date('Y') - 1,
        'maxYear' => date('Y'),
        'empty' => true,
    ),
    'field3',
));
deizel
Hi deizel, thank you for your response... yes that works, but the thing is it defeats the purpose of $form->inputs() where I don't need to list all my fields.If I only list the date fields that I want to format then it will only show the fields listed.