我想删除日期/月/年之间的斜杠(/),日期格式,在Symfony 1.4中,使用时
<?php echo $form['birthday']->renderRow(array('class' => 'date')) ?>
结果如下:
<tr>
<th><label for="profile_birthday">Birthday</label></th>
<td>
<select class="date" name="profile[birthday][month]" id="profile_birthday_month">
<option value="" selected="selected"></option>
<option value="1">01</option>
...
<option value="12">12</option>
</select>
/
<select class="date" name="profile[birthday][day]" id="profile_birthday_day">
<option value="" selected="selected"></option>
<option value="1">01</option>
...
<option value="31">31</option>
</select>
/
<select class="date" name="profile[birthday][year]" id="profile_birthday_year">
<option value="" selected="selected"></option>
<option value="2006">2006</option>
...
<option value="2016">2016</option>
</select>
</td>
</tr>
但我想:
<tr>
<th><label for="profile_birthday">Birthday</label></th>
<td>
<select class="date" name="profile[birthday][month]" id="profile_birthday_month">
<option value="" selected="selected"></option>
<option value="1">01</option>
...
<option value="12">12</option>
</select>
<select class="date" name="profile[birthday][day]" id="profile_birthday_day">
<option value="" selected="selected"></option>
<option value="1">01</option>
...
<option value="31">31</option>
</select>
<select class="date" name="profile[birthday][year]" id="profile_birthday_year">
<option value="" selected="selected"></option>
<option value="2006">2006</option>
...
<option value="2016">2016</option>
</select>
</td>
</tr>
答案 0 :(得分:3)
您可以在表单类中更改窗口小部件的日期格式。将以下代码添加到configure()
中的lib/form/doctrine/MyForm.class.php
方法:
$this->setWidget('foo', new sfWidgetFormDate(
array('format' => '%month% ... %day% ... %year%')
));
在您的案例中用适当的名称替换窗口小部件名称foo
。希望这会有所帮助:)
修改强>
You can find more information on sfWidgetFormDate and other widgets here