2016-08-07 4 views
0

CgridViewをフィルタリングして、Authassignment Modelの「学生」ロールのみを表示するようにしたいと思っています。 助けてください、これは私の論文に関連しています。ロールに基づくcgridviewのカスタムビュー

<?php 

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'users-grid', 
    'dataProvider'=>$model->search(), 
    // 'filter'=>$model, 
    'columns'=>array(

     'userID', 
     'lastname', 

     array(
      'class'=>'bootstrap.widgets.TbButtonColumn', 
     ), 
    ), 
)); 

?> 

 

StudentView

+0

のような方法下記によってのみ、学生roleを得ることができることはあなたのAuthassignmentモデルのGridViewのですか?またはあなたのユーザーモデル? –

+0

これはユーザーモデル –

+0

のものです.YIIのロールベースのアクセスについては、このURLを参照できます:http://www.yiiframework.com/doc/guide/1.1/ja/topics.auth** –

答えて

0

こんにちは、あなたのtable structureがあるが、これを行うための最善の方法は、かもしれいただきました!私は知らないの提案

としてこれを参照してください。 user_roleという名前user tableにして1 for admin 2 for studentのように、この中にユーザー作成の挿入値の時にfieldを作成し、あなたが簡単に

public function actionIndex() 
    { 
     $model=new User('search'); 

     $model->unsetAttributes(); // clear any default values 
     $model->user_role = 2;// for student role 
     if(isset($_GET['User'])) 
      $model->attributes=$_GET['User']; 

     $this->render('index',array(
      'model'=>$model, 
     )); 
    } 
関連する問題