用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2896|回复: 1
收起左侧

[HELP] 表单验证里的set_checkbox()不好用

[复制链接]
发表于 2010-5-5 23:51:08 | 显示全部楼层 |阅读模式
不知道是不是我RP不好,把CI手册里的代码复制粘贴到我的项目里就是不好用.
PHP复制代码
 
set_checkbox()
Permits you to display a checkbox in the state it was submitted. The first parameter must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:
 
<input type="checkbox" name="mycheck[]" value="1" <?php echo set_checkbox('mycheck[]', '1'); ?> />
<input type="checkbox" name="mycheck[]" value="2" <?php echo set_checkbox('mycheck[]', '2'); ?> />
 
复制代码

手册里这么写的,可到我这就记不住checked状态,只有checkbox复选框的name不是带[]的并且不重名的才好用.这该怎么办啊,我就需要用带[]的复选框啊..
发表于 2013-7-9 14:17:26 | 显示全部楼层
貌似需要设置一下
$this->form_validation->set_rules('checkbox_name', 'XXX', 'required');

本版积分规则