I have multiple check boxes from my View but it returns NULL value when passed to Controller.
I've searched (here, and here, and from other sites) for all possible answers to my problem but nothing helped.
Here are some of my CI codes:
Model (My_Model)
public function get_query_array($query_statement)
{
$query = $this->db->query($query_statement);
return $query->result();
}
Controller (view_leave)
$data["leave_list"] = $this->My_Model->get_query_array("SELECT * FROM Leave_List WHERE Leave_Status='ACTIVE'");
$this->load->view('header_view');
$this->load->view('view_leave', $data);
$this->load->view('footer_view');
PHP/HTML (view_leave.php)
<form role="form" method="post" action="<?php echo base_url();?>index.php/home/update_leave" >
<?php
// assign all leave data into checkboxes and will be submitted to /updated_leave
foreach($leave_list as $row)
{
echo "<input type='checkbox' name='leave_types[]' value='".$row->Leave_Code."'> ".$row->Leave_Description."<br/>";
}
?>
<input type="submit" value="Submit" name="submit_form" id="submit_form">
</form>
Controller (update_leave)
$data = $this->input->post('leave_types');
var_dump($data);
// Here I got some errors when I checked on the boxes
// I use the code above to check if my check boxes are working
// Unfortunately, it returns a NULL value
Why and how can I check for the checkbox values?
Please help.
Thanks!