Cakephp 4 表单助手:为日、月和年创建单独的下拉列表

因此,在 CakePHP 3 中,要得到这样的结果:

http://img2.sycdn.imooc.com/64a958d5000161e603600222.jpg

我会这样做:


 <?= $this->Form->date('dob', [

   'templates' => ['inputContainer' => '{{content}}'], 'label' => false, 'class' => 'form-control', 'minYear' => 1940, 'maxYear' => date('Y') - 5,

   'empty' => [

      'year' => "Year", // The year select control has no option for empty value

      'month' => 'Month', // The month select control does, though

      'day' => 'Day', // The month select control does, though

   ],

 ]) ?>

然而,如果我尝试在 Cakephp 4 上做同样的事情,我会得到这个

http://img3.sycdn.imooc.com/64a958e500012f3602640311.jpg

请问如何在 Cakephp 4 上实现相同的 Cakephp 3 输出


qq_花开花谢_0
浏览 71回答 1
1回答

至尊宝的传说

你试过了吗'type' => 'select'如记录的那样?否则,自定义模板可能会有所帮助。
打开App,查看更多内容
随时随地看视频慕课网APP