【发布时间】:2018-06-25 01:02:12
【问题描述】:
我必须使用 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函数 -
function checkbox_tag($name, $value = '1', $checked = false, $options = array()) { $html_options = array_merge(array('type' => 'checkbox', 'name' => $name, 'id' => get_id_from_name($name, $value), 'value' => $value), _convert_options($options)); if ($checked) { $html_options['checked'] = 'checked'; } return tag('input', $html_options); -
向我们展示
tag函数,因为实际上您将name分配给输入 -
function tag($name, $options = array(), $open = false) { if (!$name) { return ''; } return '<'.$name._tag_options($options).(($open) ? '>' : ' />'); } -
看来你的功能很多,我们也来看看
_tag_options
标签: php symfony checkbox symfony1 symfony-1.4