Welcome Guest, Not a member yet? Register   Sign In
Generating multiple checkbox from database

(This post was last modified: 07-25-2022, 10:08 AM by humbucker. Edit Reason: error )


Is it possible to use the form helper 
to generate a checkbox group of multiple values stored in my database ?
This would be used to generate a search filter sidebar, based on values stored in database.

If it's only possible to generate one checkbox tag at a time, what's the best approach to code this ?
I need to be able to retrieve the user selected values to tick or untick these checkboxes.

Thank you

Use foreach. Set form method as GET. For edited fields use data in _GET or $settings['key'] default

PHP Code:
foreach ($settings as $k => $v) {
    echo form_checkbox(...); // Here  set array options with value, is checked...

Get values form in controller

PHP Code:

Thank you, you pointed me in the right direction !

Theme © iAndrew 2016 - Forum software by © MyBB