[eluser]Unknown[/eluser]
I have a form with checkbox inputs that visitor should select atleast one of checkboxes ...
after few hours searching and testing I found a weird issue !
Controller:
Code:
$this->form_validation->set_rules('selected_checkboxes', 'Checkboxes', 'required|isset');
if ($this->form_validation->run() != FALSE)
{
//one of checkboxes selected .. countiune processing...
}
$this->load->view('form');
View 1 :
Code:
<?php echo validation_errors(); ?>
<form method=post>
<input type="checkbox" name="selected_checkboxes[]" value="1" />A <br>
<input type="checkbox" name="selected_checkboxes[]" value="2" />B <br>
<input type="submit" value="submit">
</form>
View 2 :
Code:
<?php echo validation_errors(); ?>
<form method=post>
<input type="hidden" name="jsfsdf" value="dfdfsdg"> // <<<<<<<<=============
<input type="checkbox" name="selected_checkboxes[]" value="1" />A <br>
<input type="checkbox" name="selected_checkboxes[]" value="2" />B <br>
<input type="submit" value="submit">
</form>
in the first view when I am submitting the form without selecting any checkbox its not showing any error ! but when selecting one of checkboxes its working fine ...
but in the second view when I added a input in the form ( it doesn't matter what the input type is ! text or hidden or ... ), form validating is working fine !
mean when I don't select any of checkboxes its showing validating error !
I don't know what miracle is doing that extra input in the form ...
Thanks