[在此处输入图片描述] [1]我想使用“编辑”按钮重新填充我的表单 单击编辑按钮后,它将显示要显示的所有选定项目
<input type="checkbox" id="mycheck1" name="certid[]"
value="1" class="cbx" <?php echo set_checkbox('certid','1');?>
控制器
$data['getcert'] = $this->User_Model->getcert();
output should be in the form of array
Array
(
[id] => 1
[certificate_id] => 1
[fee] => 500
[APPNO] => 10001
[regno] => 01107402042
[certid] => 1
[noc] => 2
[paid] => 1000
)
<?php foreach($getcert as $student){
echo '<pre>';
print_r($student);
echo '</pre>';
?>
<td width="50px" align="center">1</td>
<td>Transcripts & Degree Certificate Attestation</td>
<td align="center"><input type="checkbox" id="mycheck1" name="certid[]"
value="<?php echo (!isset($student['certid'])) ? 1 : $student['certid']
?>"
class="cbx" <?php echo set_checkbox('certid[]','1');?> ></td>
<td> 500 </td>
<td> <input type="number" id="primaryincome1" min="1" max="999"
name="noc[]"
value="<?php echo (!isset($student['noc'])) ? '' : $student['noc'] ?>"
disabled> </td>
<div class="col-xs-2">
<td ><input type="text" id="totalamountremaining1" name="txt"
class="text-right" value="<?php echo (!isset($student['paid'])) ? 0 :
$student['paid'] ?>" size="5"></td>
</div>
that certid value only be placed in checkbox
此值存储在db中。如何在此视图中分配该值?
答案 0 :(得分:0)
这不是您问题的直接答案,但是您将了解如何执行此操作。
在HTML中:
Height
在控制器中:
The Black Grid
使用此方法,您可以将数组数据从前端传递到控制器。
答案 1 :(得分:0)
正确的是,显然@sys.any:bug
是从表单验证重新填充字段时要使用的东西。例如。该字段具有后置值,并且验证失败时需要将该后置值取回。因此,确定db字段是否与复选框值匹配并不是真正的事情。
现在,我假设您想要的逻辑是,如果parameter named bug
的db中的值为1,则应选中该复选框。在这种情况下,您可以执行以下操作:
set_checkbox()
答案 2 :(得分:0)
尝试:
<input type="checkbox" id="mycheck1" name="certid[]"
value="1" class="cbx" <?php echo set_checkbox('certid','1', $certid==1;?>>
以$certid
作为您的数据库值
摘自手册:
第三个(可选)参数可让您将一项设置为默认项(使用布尔值TRUE / FALSE)'
因此,您可以测试db值是否适合复选框值,仅此而已。