CGridView With Multiple Checkboxes Per Row

I have a CGridView with two checkbox columns. I am able to display the grid with the multiple checkboxes per row, and with preset checked values based on data in the database. :slight_smile:

My Question: how can I send data to my controller containing information about each rows checked state, for each column containing a checkbox?

The checkbox columns are used to indicate if a client has received a particular type of service. I have created the grid with the following code:




        $this->widget('zii.widgets.grid.CGridView', array(

            'id'=>'service-grid',

            'dataProvider'=>$clients->search(),

            'columns'=>array(

                'first_name',

                'last_name',

                array(

                    'header'=>'Education',

                    'class'=>'CDataColumn',

                    'type'=>'raw',

                    'htmlOptions'=>array('style'=>'text-align:center'),

                    'value' => 'CHtml::checkBox("esid[]", $data->education, array("value"=>$data->wc_client_id,"id"=>"esid_".$data->wc_client_id))',

                ),

                array(

                    'header'=>'Health',

                    'class'=>'CDataColumn',

                    'type'=>'raw',

                    'htmlOptions'=>array('style'=>'text-align:center'),

                    'value' => 'CHtml::checkBox("hsid[]", $data->health, array("value"=>$data->wc_client_id,"id"=>"hsid_".$data->wc_client_id))',

                )

            ),

        ));  



I have found a way to retrieve the IDs of the selected columns for each of my checkbox columns in my controller. Here is the code I have in my controller to retrieve the selected IDs:




        $healthClientId = array();

        if(isset($_POST['hsid']) && is_array($_POST['hsid']))

        {

          $healthClientId = $_POST['hsid'];

        }


        $educationClientId = array();

        if(isset($_POST['esid']) && is_array($_POST['esid']))

        {

          $educationClientId = $_POST['esid'];

        }