CodeIgniter Forums
CodeIgniter edit checkbox showing error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: CodeIgniter edit checkbox showing error (/showthread.php?tid=71113)



CodeIgniter edit checkbox showing error - azmath - 07-07-2018

My code is : 
                                        <label class="checkbox-inline">

                                          <input type="checkbox" name="Stake_Holder" value="Stake_Holder" <?php if($data['Stake_Holder'] == 'Stake_Holder'){echo 'checked';}?>/>Stake Holder
                                        </label>
///////////////////////////////////////////////////////////////////////

Error showing: A PHP Error was encountered Severity: Notice
Message: Undefined variable: data
Filename: superadmin/client_view.php
Line Number: 73
Backtrace:
File: C:\xampp\htdocs\ciall\ciautomation\application\views\superadmin\client_view.php Line: 73 Function: _error_handler
File: C:\xampp\htdocs\ciall\ciautomation\application\controllers\Client_con.php Line: 37 Function: view
File: C:\xampp\htdocs\ciall\ciautomation\index.php Line: 315 Function: require_once
/>Stake Holder

I want echo checked


RE: CodeIgniter edit checkbox showing error - InsiteFX - 07-08-2018

Without see your controller code I would say that $data['Stake_Holder'] should be $Stake_Holder


RE: CodeIgniter edit checkbox showing error - Pertti - 07-08-2018

Check that you've passed $data in the view:

PHP Code:
$this->load->view('viewfile', ['data' => $data]); 



RE: CodeIgniter edit checkbox showing error - Gurutechnolabs - 11-01-2018

<input type="checkbox" name="accept_terms_checkbox" value="Accept TOS" <?php echo set_checkbox('accept_terms_checkbox', 'Accept TOS'); ?> /> Accept Terms of Services

<input type="checkbox" name="M0140" value="1"  <?php echo ($result->M0140== "1" ) ? "checked" : set_checkbox('M0140, '1',$result->M0140== "1"); ?> size="1">

I think you have to try this...