我想在CodeIgniter Web应用程序上创建多个单选按钮,但是在提交表单后,此值为null
。
这是我对Codeigniter应用的看法
<?php $no=0; foreach ($catsub_1_isi as $list2_1a_1a): $no++ ?>
<form role="form" method="post" action="<?php echo base_url('c_QA_roe/simpan_list'); ?>">
<input type="hidden" name="WSDetailID[]" value="<?php echo $kode_detail;?>" class="form-control">
<input type="hidden" name="WSHeaderID[]" value="<?php echo $judul->WSHeaderID;?>" class="form-control">
<input type="hidden" name="AppDate[]" value="<?php $tgl=date('Y-m-d-H-i-s'); echo $tgl; ?>" class="form-control">
<input type="hidden" name="InputDate[]" value="<?php $tgl=date('Y-m-d-H-i-s'); echo $tgl; ?>" class="form-control">
<input type="hidden" name="InputUser[]" value="<?php echo $UserName; ?>" class="form-control">
<input type="hidden" name="WSListID[]" value="<?php echo $list2_1a_1a->WSListID;?>" class="form-control">
<tr>
<td><?php echo $no;?></td>
<td><?php echo $list2_1a_1a->Subject;?></td>
<td><?php echo $list2_1a_1a->Standard;?></td>
<td align="center">
<div class="radio">
<input type="text" name="YesNo[<?php echo $list2_1a_1a->WSListID;?>]" value="0">
<input type="radio" name="YesNo[<?php echo $list2_1a_1a->WSListID;?>]" class="minimal" value="<?php echo $list2_1a_1a->Value;?>" checked>Y
<input type="text" name="YesNo[<?php echo $list2_1a_1a->WSListID;?>]" value="0">
<input type="radio" name="YesNo[<?php echo $list2_1a_1a->WSListID;?>]" class="minimal" value="<?php echo $list2_1a_1a->Value;?>">N
</div>
</td>
<td align="center">
<select name="IsRedudance[]">
<option value="0">-</option>
<option value="<?php echo $list2_1a_1a->Value;?>">Yes</option>
</select>
</td>
<td align="center">
<select name="IsUse[]">
<option value="YES">Yes</option>
<option value="NO">No</option>
</select>
</td>
</tr>
<?php endforeach;?>
这是我在codeigniter应用程序上的控制器
public function simpan_list()
{
$WSDetailID = $this->input->post('WSDetailID[]');
$WSHeaderID = $this->input->post('WSHeaderID[]');
$WSListID = $this->input->post('WSListID[]');
$IsYes = $this->input->post('IsYes[]');
$IsNo = $this->input->post('IsNo[]');
$IsRedudance = $this->input->post('IsRedudance[]');
$IsUse = $this->input->post('IsUse[]');
$AppDate = $this->input->post('AppDate[]');
$InputDate = $this->input->post('InputDate[]');
$InputUser = $this->input->post('InputUser[]');
$Yes = $this->input->post('YesNo[]');
$No = $this->input->post('YesNo[]');
$data = array();
$index = 0;
foreach($WSDetailID as $datanis)
{
array_push($data, array(
'WSDetailID' =>$datanis,
'WSHeaderID' =>$WSHeaderID[$index],
'WSListID' =>$WSListID[$index],
'IsYes' =>$Yes[$index],
'IsNo' =>$No[$index],
'IsRedudance' =>$IsRedudance[$index],
'IsUse' =>$IsUse[$index],
'AppDate' =>$AppDate[$index],
'InputDate' =>$InputDate[$index],
'InputUser' =>$InputUser[$index],
));
$index++;
var_dump($data['IsYes']);
}
}
在我的控制器上,我对$YesNo
(尤其是多个单选按钮)的变量上的POST数据感到困惑,所以我试图使post('YesNo[]')
正确吗?但该值仍为
答案 0 :(得分:0)
没有复选框。但是如果要发布复选框的值。您可以通过这种方式发布。
//视图
<input type="checkbox" name="active" placeholder="Active" checked >
//控制器
'field_name' => ($this->input->post('field_name') == "true") ? 1 : 0;