iyuki0430 发表于 2010-5-5 23:51:08

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

不知道是不是我RP不好,把CI手册里的代码复制粘贴到我的项目里就是不好用.

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不是带[]的并且不重名的才好用.这该怎么办啊,我就需要用带[]的复选框啊..

martinwangjun 发表于 2013-7-9 14:17:26

貌似需要设置一下
$this->form_validation->set_rules('checkbox_name', 'XXX', 'required');
页: [1]
查看完整版本: 表单验证里的set_checkbox()不好用