[英]I can't the contents of my checkbox (symfony 1.0)
我必須使用Symfony 1(是的,我知道它已經很老了)。 我必須做一個表格,用戶可以通過復選框輸入多個選擇。 除了當我選中一個以上的復選框時,我僅獲得最后一個復選框的內容
我有這個:
<tr>
<th>Est prolongé :</th>
<td>
<?php echo checkbox_tag('motif', '1'); ?>
</td>
</tr>
<tr>
<th>Est interrompu :</th>
<td>
<?php echo checkbox_tag('motif', '2'); ?>
</td>
</tr>
public function executeAddFormAvenant()
{
sfLoader::loadHelpers('Url');
// Enregistremant d'un nouvel avenant :
$avenant=new ConvFormAvenant();
$avenant->setIdConvConvention($this->getRequestParameter('id_convention'));
$conv_convention = ConvConventionPeer::retrieveByPk($this->getRequestParameter('id_convention'));
if ($this->getRequestParameter('motif')==1)
{
$avenant->setEstProlongé(1);
} else{
$avenant->setEstProlongé(0);
}
if ($this->getRequestParameter('motif')==2)
{
$avenant->setEstInterrompu(1);
} else{
$avenant->setEstInterrompu(0);
}
在不了解有關checkbox_tag()
函數的任何情況下,我只能建議在以下幾行中將第一個參數更改為motif[]
:
<?php echo checkbox_tag('motif', '1'); ?>
<?php echo checkbox_tag('motif', '2'); ?>
輸出將仍然是motif
沒有括號。 如果使用該參數命名復選框,則會將行為更改為具有值而不是單個值的數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.