How to change order of Date of Birth Fields in CakePHP 3 Form

635 views Asked by At

I am comparatively new to CakePHP3. I am creating a form with a Date of Birth field in it, with dob field name.

echo $this->Form->input('dob',['label'=>'Date of Birth']);

Fields are rendered in Year - Month - Day sequence. I want it be rendered in Day - Month - Year sequence. I have been checking the CakePHP3 documentation for sometime now but I am not able to change the order of the date fields. Here is how it is rendered:

enter image description here

Please guide me. Thanks in Advance.

1

There are 1 answers

0
Arvind K. On

Oh I found it here, in the FormHelper API documentation! There is dateWidget template in 'templates' which one can use to change the default sequence of date fields. For example I had to do like this:

echo $this->Form->input('dob',['label'=>'Date of Birth', 'templates' => ['dateWidget' => '{{day}}{{month}}{{year}}']]);