CakePHP 3 date input format

2019-09-15 04:04发布

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.

1条回答
孤傲高冷的网名
2楼-- · 2019-09-15 04:39

easiest way is

$this->Form->templates(
  ['dateWidget' => '{{day}}{{month}}{{year}}']
);
echo $this->Form->input('date', ['type'=>'date']);
查看更多
登录 后发表回答