user152235
user152235

Reputation: 89

specifying date format when using $form->inputs() in CakePHP

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.

Upvotes: 3

Views: 6415

Answers (1)

deizel.
deizel.

Reputation: 11212

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',
));

Upvotes: 7

Related Questions