CakePHP 3日期输入格式 [英] CakePHP 3 date input format

查看:74
本文介绍了CakePHP 3日期输入格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始将Cake版本从2.x升级到3.x,所以我的问题是在提交表单上输入的日期:

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)我需要格式日期将为DMY,但它表明YMD我一直在搜索可能是语言环境问题或验证程序,但仍给出该格式。

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)我的模板有:

        '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>',  ],

如您所见,选择为每个显示的选择赋予一个新的div,在蛋糕日期显示在日期,月和年的选择组上(3个选择),在2.x中内联显示,但在3.x它在另一个下面显示一个原因,导致其创建另一个div。
如果可以帮助我,cz这个版本的文档和帖子都很差,我需要升级我的项目。谢谢。

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.

推荐答案

最简单的方法是

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

这篇关于CakePHP 3日期输入格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆