0

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

请注意下拉列表的名称属性都是“生日”。如何在 cake 中更改它,以使上面三个下拉列表的名称属性不完全相同?我希望它们类似于“birthday_month”、“birthday_year”和“birthday_day”。

4

2 回答 2

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

它将在帖子中生成相同的输出,请询问是否不适合您..

于 2012-08-17T04:40:34.797 回答
-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'));
于 2014-06-28T17:42:17.203 回答