我有这个:
<?php echo $this->Form->input('Schedule.0.end_date', array(
'minYear' => date('Y'),
'maxYear' => date('Y')+5
)); ?>
我想将默认日期设置为今天以外的日期。这可以通过 CakePHP 的表单助手实现吗?
我发现一篇文章展示了如何使用 TIME 来实现它 - 但尝试通过设置“日”,“月”,“年”进行类似的操作没有任何效果。
最佳答案
您可以使用 $this->Form->input();
的 selected
参数来实现这一点。尝试这样:
<?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'
));
?>
关于forms - 有没有办法在 CakePHP 日期表单输入中设置默认日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5984061/