我想添加“月”、“日”、“年”作为生日菜单助手中的首选?这可以做到吗?我没有看到任何如何执行此操作的示例?下面是我的代码:
<?php echo $this->Form->input('date_of_birth',
array(
'type' => 'date',
'label' => 'Date of Birth:<span>*</span>',
'dateFormat' => 'MDY',
'empty' => true,
'minYear' => date('Y')-130,
'maxYear' => date('Y'),
'options' => array('1','2')
)
);
?>
谢谢, 巴特
最佳答案
给你,the empty
option accepts an array您可以在其中使用键 month
、year
、day
、hour
为各个字段指定空值, 分钟
和子午线
:
echo $this->Form->input('date_of_birth',
array(
'type' => 'date',
'label' => 'Date of Birth:<span>*</span>',
'dateFormat' => 'MDY',
'empty' => array(
'month' => 'Month',
'day' => 'Day',
'year' => 'Year'
),
'minYear' => date('Y')-130,
'maxYear' => date('Y'),
'options' => array('1','2')
)
);
关于forms - cakephp生日助手自定义默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17406169/