Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How add a toggle button for active inactive in Yii CGridView

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.64k
    Comment on it

    How add a toggle button for active inactive in Yii CGridView

    <?php $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'subject-grid',
        'dataProvider'=>$model->search(),
    
        'columns'=>array(
            'id',
            'subjectName',
       array(
                'header'=>'Status',
                'class'=>'CButtonColumn',
    
                'template'=>'{activate}  {rejected}',
                'buttons'=>array(
                    'activate'=>array(
                        'label'=>'<img src="'.$publishImageUrl.'">',
                        'visible'=>'$data->status==1',
                        'url'=>'Yii::app()->createUrl("subject/changestatus",array("id"=>$data->id,"status"=>0))',
                        'options'=>array('confirm'=>'Are you sure want to unpublish?'),
    
                    ),
    
    
                    'rejected' =>array(
                        'label' =>'<img src="'.$unpublishImageUrl.'">',
                        'visible'=>'$data->status==0',
                        'url'=>'Yii::app()->createUrl("subject/changestatus",array("id"=>$data->id,"status"=>1))',
                        'options'=>array('confirm'=>'Are you sure want to Publish?'),
                    ),
                ),
    
            ),
    
        ),
    )); ?>
    

    when user click on button a confirm message will come

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: