How to delete multi when check box

My picture https://dl.dropboxusercontent.com/u/109046499/Selection_023.png

I want to delete all record when check all box, but if use function

           public function deleteAction($id) {
               //$Hososinhvien = Hososinhvien::findFirstById($id);      
                $Hososinhvien = Hososinhvien::find($id)
        }

where $id is array if check all box, how to hint

Describe not only one, but the easiest way.

Give all your check boxes the same name, and have that name end with []:

<input type="checkbox" name="item[]" value="1" />
<input type="checkbox" name="item[]" value="2" />
<input type="checkbox" name="item[]" value="3" />
<input type="checkbox" name="item[]" value="4" />
<input type="checkbox" name="item[]" value="5" />

Then your script gets all the checked values as an array:

public function saveAction() {

    // Check if request has made with POST
    if ($this->request->isPost() == true) {

        // Access POST data
        $deleteItems = $this->request->getPost("item");

        // Delete all of them =)
        foreach ($deleteItems as $item) {
            Hososinhvien::findFirst($item)->delete();
        }

    }

}


37.8k

Thank Maxim Borzov, i slove