CodeIgniter Forums
Checkbox Group using Form helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Checkbox Group using Form helper (/thread-26660.html)



Checkbox Group using Form helper - El Forum - 01-20-2010

[eluser]Federico Gonzalez[/eluser]
Hi,

How can I make a Checkbox Group using the Form Helper?

Controller:
$data = array(xxxxx);

View:
<?php echo form_checkbox(xxx) ?>

Need I put some foreach in view?

Thanks!


Checkbox Group using Form helper - El Forum - 01-20-2010

[eluser]flaky[/eluser]
yep
Code:
//Controller
$data['checkbox_list'] = array('item_1', 'item_2');\

//View
<?php foreach($checkbox_list as $checkbox){ ?>
    <?php echo form_checkbox($checkbox, 'some_val'); ?>
<?php } ?>