CGridview conditional delete button

zuups picture zuups · Feb 24, 2012 · Viewed 12.3k times · Source

I want the delete button to be active only in certain condition in CGgridView CButtonColumn (or make a custom delete button) e g if user=='admin' or status=='draft'. Any ideas? Thanks!

Answer

Mukesh Soni picture Mukesh Soni · Feb 24, 2012

use 'visible' parameter -

 'buttons'=>array
    (
        'delete' => array
        (
            'label'=>'Delete',
            //other params
            'visible'=>!Yii::app()->user->checkAccess('admin'),
        ),