tags:

views:

43

answers:

2

Hi,

I'll describe the problom as clearly as I can.

I have activeDataProvider:

$dataProvider=new CActiveDataProvider('Menu', array(
    'criteria'=>array(         
       'with' => array('roles'),
    ),
));

then I'am using CGridView with checkbox:

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'menu-grid',
'selectableRows' => 2,
'dataProvider'=>$dataProvider,
'columns'=>array(
        'id',
        'title',
         array(
            'class'    => 'SCheckboxColumn',
            'header'   => 'View',
            'name'     => 'Roles[Actions][can_view]',
            'id'       => 'roles_action_can_view',
             'value'    => '$data->id',
            'checkBoxHtmlOptions' =>
                array('checked' => $data->roles->can_view,),
        ),
    ),
));

Then in Menu Model relations:

return array(
        'roles' => array(self::HAS_MANY, 'Rolesmenus', 'menu_id'),
    );

and in Rolesmenus Model relations:

return array(
        'menu' => array(self::BELONGS_TO, 'Menu', 'menu_id'),
    );

So, I cant access $data->roles->can_view variable, when I var_dump all $data object I can see these atributes in _atributtes private array but I cant them access through CGridView.

Any ideas??

A: 

array('checked' => $data->roles->can_view,),

needs to be array('checked' => '$data->roles->can_view',),

nsbucky
A: 

Yes, it's ok, I have found it in.

Thanx!

ignas
You should have added this as a comment to the answer. Plus, mark that answer as accepted.
kitsched