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

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

Hello

Is it possible to use the form helper 
Code:
form_checkbox
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
Reply
#2

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:
$request->getGet('settings_key'$settings['settings_key']); 
Reply
#3
Tongue 

Thank you, you pointed me in the right direction !
Reply




Theme © iAndrew 2016 - Forum software by © MyBB