I have an array of two checkboxes in a form, setup the way this question suggests. Validation appears to fail, correctly, when no checkbox is selected but it looks like form_validation doesn't even run against empty checkboxes? Relevant code:
$this->form_validation->set_rules('groupcheck[]', 'groupcheck', 'required');
With no checkboxes selected this produces no errors when submitted (bad), and "validates" to false (good). When a checkbox is checked no errors are produced (good) and the form validates true (good).
Changing the validation to something which will always fail:
$this->form_validation->set_rules('groupcheck[]', 'groupcheck', 'valid_email');
With no checkboxes selected this produces no errors when submitted (bad), and "validates" to false (good). When a checkbox is checked a valid email error is produced (good) and the form validates false (good).
So is this an issue with the browser not returning any data to form_validation when no checkboxes are selected? How would you go about displaying errors when a checkbox isn't selected?