There is a checkbox, it is visually disabled (unchecked), but its html is:

<input type="checkbox" name="type_edit[]" value="1" checked="checked"> 

The handler is:

 if($this->input->post('type_edit')) { foreach($this->input->post('type_edit') as $val){ $data[] = $val; } var_dump($data); die(); // ничего не выводит } // не заходит в это условие 

Why is that?

  • one
    You yourself wrote that it does not enter the condition. Here var_dump() does not print anything. Make var_dump ($ this-> input-> post ('type_edit')) before this condition; and show what's in it - Johny

3 answers 3

visually it is disabled (unchecked)

Well then, what is the question? Check the box to get $_POST['type_edit'] not empty (or rather, to get it at all)

If the checkbox is not checked, it is not passed in the form

    try the following code:

     $result = array(); foreach($_POST['type_edit'] as $data) $result[] = $data; print_r($result); 

    if it does, then the problem is with

     $this->input->post('type_edit') 
    • The output is null and swears at foreach Invalid argument supplied for foreach () - IOleg

    why attribute to assign something. Try simple: <input type="checkbox" name="type_edit[]" value="1" checked>