pass a variable into CGridView so I can use it with 'visible'




                array(

                        'class' => 'CButtonColumn',

                        'template' =>'{view} {update} {export}',

                        'buttons' => array(

                                'update' => array(

                                    'label' => 'Transfer',

                                    'imageUrl' => '/images/icons/next.png'

                                ),

                                'install' => array(

                                    'label' => 'Install',

                                    'imageUrl' => '/images/icons/select.png',

                                    'url' => 'Yii::app()->createUrl( Yii::app()->controller->id . "/export/" . $data["id"])',

                                    'visible' => 'in_array($data->currentlocation->location->id, $engineerlocations) ? true : false',

                                ),

                        ),

                ),



I would like to pass in $engineerlocations into the visible expression, is that possible?

Use an anonymous function and the "use" keyword:




'visible' => function($data) use ($engineerlocations){

    return in_array($data->currentlocation->location->id, $engineerlocations);

},



Thanking you!