Welcome Guest, Not a member yet? Register   Sign In
Yet another set_checkbox() validation re-population question
#1

[eluser]helloworldly[/eluser]
I see a bunch of posts about checkbox validation re-population but they seem to be either outdated (pre latest edition of CI), do not define the solution clearly, or do not apply exactly to this case.

I'm using CI's form validation and it works elsewhere but I can't get set_checkbox() working when using multiple checkboxes as an array.

Within the form within the view:
Code:
<input type="checkbox" value="ABC" name="group[]" <?php echo $this->validation->set_checkbox('group[]', 'ABC'); ?> />
<label>ABC</label><br/>

&lt;input type="checkbox" value="XYZ" name="group[]" &lt;?php echo $this-&gt;validation->set_checkbox('group[]', 'XYZ'); ?&gt; />
<label>XYZ</label><br/>

// This doesn't work either:
&lt;input type="checkbox" value="XYZ" name="group[]" &lt;?php echo $this-&gt;validation->set_checkbox('group', 'XYZ'); ?&gt; />

Controller:
Code:
// Assign rules
$rules['group[]'] = "required";
$rules['anothergroup[]'] = "required";

// This doesn't work either:
$rules['group'] = "required";

$this->validation->set_rules($rules);

Thanks for any help.


Messages In This Thread
Yet another set_checkbox() validation re-population question - by El Forum - 07-14-2010, 01:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB