Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGridview conditional delete button

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!

like image 671
zuups Avatar asked Feb 24 '12 11:02

zuups


2 Answers

use 'visible' parameter -

 'buttons'=>array
    (
        'delete' => array
        (
            'label'=>'Delete',
            //other params
            'visible'=>!Yii::app()->user->checkAccess('admin'),
        ),
like image 199
Mukesh Soni Avatar answered Oct 25 '22 01:10

Mukesh Soni


'visible'=>'$data->status=="draft" || Yii::app()->user->checkAccess("admin")'
like image 41
user1584091 Avatar answered Oct 25 '22 01:10

user1584091