CodeIgniter Forums
repopulate array checkbox - 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: repopulate array checkbox (/showthread.php?tid=29550)



repopulate array checkbox - El Forum - 04-13-2010

[eluser]Schumacher[/eluser]
So, im mkaing this site where i need to have some informations on the user, so i have a a few checkboxes that can be checked, but the problem is that i can't find a way to repopulate the checked boxes after the form_validation has failed.

i tried in every way the user guide told me, but it just dosn't work .
i have :

$data = array( 'name' => 'seek[]',
'value' => $key,
);
echo "<span class='checkbox'>".form_checkbox($data['name'], $data['value'], '', set_checkbox($data['name'], $data['value']))." ".$value."</span>";

but this just dosn't work.
before i had

form_checkbox($data);

but i tried the other thing to see if it worked then.
i think the problem is that the set_checkbox() returns checked = checked, but the from_checkbox() only wants true or false.

hope you can help Smile


repopulate array checkbox - El Forum - 04-13-2010

[eluser]Schumacher[/eluser]
Ahh, found the problem. After i seached the forum a little more i found out that i still needed the have rules set on the array checkbox before it could repopulate.