2011-07-13 3 views
0

私はsymfony 1.4、使用につながるタイプdateのrenderRowからスラッシュを削除するにはどうすればよいですか?

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

答えて

3

フォームクラスのウィジェットの日付形式を変更することができます。

$this->setWidget('foo', new sfWidgetFormDate(
    array('format' => '%month% ... %day% ... %year%') 
)); 

はあなたのケースでは、適切な名前を持つウィジェット名fooの交換:lib/form/doctrine/MyForm.class.phpconfigure()メソッドに次のコードを追加します。ホープこのことができます:)

編集:

You can find more information on sfWidgetFormDate and other widgets here

関連する問題