Alejandro Cabano
Alejandro Cabano

Reputation: 155

CakePHP 3 date input format

im starting upgrading my Cake version from 2.x to 3.x, so my problem is in the date input on the submit form:

1) I need that the format date will be DMY, but it shows YMD I've been searching that maybe is the locale problem or the validator but still give that format.

2) on my template I have this:

        'shortForm' => [
        'formstart' => '<form class="form-horizontal" {{attrs}}>',        
        'formGroup' => '{{label}}{{input}}{{error}}',
        'label' => '<label class="control-label" {{attrs}}>{{text}}</label>',
        'input' => '<div class="controls"><input type="{{type}}" name="{{name}}" {{attrs}} /></div>',
        'select' => '<div class="controls"><select name="{{name}}"{{attrs}}>{{content}}</select></div>',
        'inputContainer' => '<div class="control-group{{required}}">{{content}}</div>',                 
        'inputContainerError' => '<div class="help-inline">{{content}}</div>',  ],

As you can see the select is giving a new div for each select displayed, in Cake date shows on select group for Day, Month and Year (3 selects), this is displayed inline in 2.x but in 3.x it shows one below other cause its creating another div. if you can help me cz the documentation and posts are poor for this version and I need upgrade my project. thank you.

Upvotes: 0

Views: 4011

Answers (1)

Sam Vimes
Sam Vimes

Reputation: 123

easiest way is

$this->Form->templates(
  ['dateWidget' => '{{day}}{{month}}{{year}}']
);
echo $this->Form->input('date', ['type'=>'date']);

Upvotes: 3

Related Questions