有没有办法在CakePHP日期表单输入中设置默认日期? [英] Is there a way to set the default date in a CakePHP date form input?
本文介绍了有没有办法在CakePHP日期表单输入中设置默认日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个:
<?php echo $this->Form->input('Schedule.0.end_date', array(
'minYear' => date('Y'),
'maxYear' => date('Y')+5
)); ?>
我想将默认日期设置为今天以外的日期。这是可能与CakePHP的形式助手吗?
I would like to set the default date to something other than today. Is this possible with CakePHP's form helper?
我发现一个帖子,显示如何做到与TIME - 但尝试类似的设置天,月
I found a post that showed how do to it with TIME - but trying something similar by setting "day", "month", "year" does nothing.
推荐答案
您可以使用 selected
$ this-> Form-> input();
的参数。尝试这样:
You can achieve that using the selected
parameter of $this->Form->input();
. Try like this:
<?php
echo $this->Form->input('datetime', array(
'label' => 'Date 1',
'selected' => array(
'day' => '',
'month' => '',
'year' => '',
'hour' => '',
'minute' => '',
'second' => ''
)
));
/* What's interesting... this will work aswell: */
echo $this->Form->input('datetime', array(
'label' => 'Date 2',
'selected' => '0000-00-00 00:00:00'
));
?>
这篇关于有没有办法在CakePHP日期表单输入中设置默认日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文