Welcome Guest, Not a member yet? Register   Sign In
Form Validation - set_checkbox()
#1

[eluser]webtigers[/eluser]
FYI: If you are using CI's automatic form validation (using a form_validation.php file in the /application/config folder) and cannot seem to get set_checkbox() method to work, it's because you need to set a validator for the specific checkbox(es). DOH! Yea, who the hell sets a validator on a check box, but you have to in order to get it to work.

The form validation is a very cool feature. Just a little FYI that could be in the docs because it cost me a couple of hours to dig into the CI code and dig this puppy out. Wink
#2

[eluser]Unknown[/eluser]
Thanks for the hint. I had the same problem and thought I was losing my mind.
#3

[eluser]helloworldly[/eluser]
Quote:FYI: If you are using CI’s automatic form validation (using a form_validation.php file in the /application/config folder) and cannot seem to get set_checkbox() method to work, it’s because you need to set a validator for the specific checkbox(es). DOH! Yea, who the hell sets a validator on a check box, but you have to in order to get it to work.

I'm having an issue of getting set_checkbox() working when using multiple checkboxes as an array.

Code:
// more 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/>

// more code

And
Code:
&lt;input type="checkbox" value="XYZ" name="group[]" &lt;?php echo $this-&gt;validation->set_checkbox('group', 'XYZ'); ?&gt; />
isn't working for me either.

I am using CI's form validation, but I don't see "a form_validation.php file in the /application/config folder" nor do I know how to "set a validator for the specific checkbox(es)."

Thanks for any help!
#4

[eluser]Brad K Morse[/eluser]
@helloworldly, I am having the SAME EXACT problem as you, since it is using multiple checkboxes as an array name="step_id[]" as seen here http://ellislab.com/forums/viewthread/175540/

Was your problem ever resolved? I'd love to know, thanks.




Theme © iAndrew 2016 - Forum software by © MyBB