CodeIgniter Forums
Repopulating Arrays of checkboxes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Repopulating Arrays of checkboxes (/showthread.php?tid=40314)



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

[eluser]Unknown[/eluser]
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

[eluser]Unknown[/eluser]
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 !!