Specifying the date format when using $ form-> input () in CakePHP

I am wondering if there is a way to specify the date format in forms created using CakePHP $ form-> input (); Please note that this is not a separate $ form-> input (), but instead of $ form-> input (), which will automatically create all form fields.

Any input would be appreciated. Thanks.

+3
source share
1 answer

You can pass the usual parameters to $form->inputs, which you will go to $form->input.

For example, if you want to configure field2below, you make the field name with the key and an array of parameters a 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',
));
+7

Source: https://habr.com/ru/post/1722776/


All Articles