cakephp中的下拉字段名称

时间:2012-08-16 20:23:50

标签: php cakephp cakephp-1.3

对于cakephp 1.3,我为生日创建了一个下拉菜单

 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),

            )
        );  

产生

 <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>

注意下拉列表的name属性是如何“生日”的。如何在蛋糕中更改此项,以便上面三个下拉列表的名称属性不完全相同?我希望他们像“birthday_month”,“birthday_year”和“birthday_day”。

2 个答案:

答案 0 :(得分:1)

您可以使用:

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'));

它会在帖子上生成相同的输出,请问是否不适合你..

答案 1 :(得分:-1)

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'));