dongxinxin7809 2012-08-16 20:23
浏览 40
已采纳

cakephp中的下拉字段名称

For cakephp 1.3, I've created a drop down for birthday like so

 echo $form->input('User.birthday', 
            array(

                'label' => __("form_birthday", "true") , 
                'class' => 'date',
                'selected' => 'empty',
                'dateFormat' => 'DMY',
                'minYear' => date('Y') - 90,
                'maxYear' => date('Y') - 18,
                'separator'=> " ",
                'empty' => __("form_select", true),

            )
        );  

which produces

 <div class="input date"><label for="UserBirthdayMonth">Month &amp; Year of      Birth</label><select id="UserBirthdayDay" class="date" name="birthday">
 <option value="">- Select  -</option>
 .....
 </select> <select id="UserBirthdayMonth" class="date" name="birthday">
   <option value="">- Select  -</option>
   <option value="01">January</option>
   <option value="02">February</option>
   <option value="03">March</option>
   <option value="04">April</option>
   <option value="05">May</option>
   <option value="06">June</option>
   <option value="07">July</option>
   <option value="08">August</option>
   <option value="09">September</option>
   <option value="10">October</option>
   <option value="11">November</option>
   <option value="12">December</option>
   </select> <select id="UserBirthdayYear" class="date" name="birthday">
   <option value="">- Select  -</option>
   .....
   </select></div>

Notice how the name attribute of the dropdowns are all "birthday". How can I change this in cake so that the name attributes of the three dropdowns above are not all the same? I'd like them be something like "birthday_month", "birthday_year" and "birthday_day".

  • 写回答

2条回答 默认 最新

  • dongluxin2452 2012-08-17 04:40
    关注

    You can use this :

    echo $this->Form->day('User.birthday', array('empty'=>'Day'));
    echo $this->Form->month('User.birthday', array('empty'=>'Month'));
    echo $this->Form->year('User.birthday', date('Y')-90 , date('Y') - 18,array('empty'=>'Year'));
    

    It will generate same output on post, Kindly ask if not work for you..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作