CakePHP 3:在dateWidget中更改顺序 [英] CakePHP 3: change order in dateWidget

查看:60
本文介绍了CakePHP 3:在dateWidget中更改顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CakePHP开发人员指南中找到以下有关使用 date 表单输入时如何调整字段顺序的提示。它说

I found on the CakePHP developer's guide the following hint on how to adjust the order of the fields when using the date form input. It says


要控制输入的顺序以及输入之间的任何元素/内容,您可以覆盖dateWidget模板。

To control the order of inputs, and any elements/content between the inputs you can override the dateWidget template.

但是,我在任何地方都找不到关于如何更改顺序并在视图中使用它的提示。

However, I cannot find anywhere a hint on how to change the order and use this in a view. Can you give hints?

推荐答案

您可以在初始化表单助手时配置DateWidget模板

You can configure the DateWidget template when initializing the Form helper

// in MyController.initialize()
$this->loadHelper('Form', [
    'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}'
]);

,也可以使用 templates 表单组件中的功能

or you can override the template using the templates function in the form component

$this->Form->templates([
    'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}'
]);

@see http://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the- template-formhelper-uses

这篇关于CakePHP 3:在dateWidget中更改顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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