CodeIgniter Forums
Repopulating Arrays of checkboxes - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Repopulating Arrays of checkboxes (/thread-40314.html)

Repopulating Arrays of checkboxes - El Forum - 04-05-2011

I've looked through the forums and other than modifying certain core files there seems to be no fix that is up to date ... meaning I haven't found one that wasn't over 2 years old. I have an array of check boxes representing towns a person could work in ... example ...

<INPUT TYPE=CHECKBOX NAME="coverage_areas[]" value="Cape Cod"<?php echo set_checkbox('coverage_areas[]', 'Cape Cod');?>/>Cape Cod

<INPUT TYPE=CHECKBOX NAME="coverage_areas[]" value="Boston"<?php echo set_checkbox('coverage_areas[]', 'Boston');?>/>Boston

<INPUT TYPE=CHECKBOX NAME="coverage_areas[]" value="Providence"<?php echo set_checkbox('coverage_areas[]', 'Providence');?>/>Providence

the only validation id do on this is the

$this->form_validation->set_rules('coverage_areas', 'Coverage Areas', 'required);

when the form is submitted and an error occurs the check boxes that were checked are not repopulated ... anyone got any ideas, as I said I've pretty much tried everything I came across.

Repopulating Arrays of checkboxes - El Forum - 04-05-2011

I solved it ... just an oversite ....

it was my validayion call ...

$this->form_validation->set_rules(‘coverage_areas’, ‘Coverage Areas’, ‘required);

should be ...

$this->form_validation->set_rules(‘coverage_areas[]’, ‘Coverage Areas’, ‘required);

array !!