3

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.

1 Answer 1

7

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',
));
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.