shaaz

Untitled

Jun 14th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. here is is what i have in view/post/admin.php
  2. <?php $this->widget('zii.widgets.grid.CGridView', array(
  3.     'id'=>'post-grid',
  4.     'dataProvider'=>$model->search(),
  5.     'filter'=>$model,
  6.     'columns'=>array(
  7.         'id',
  8.         'title',
  9.         'content',
  10.         'tags',
  11.         array(
  12.             'name'=>'status',
  13.             'value'=>'Lookup::item("PostStatus",$data->status)',
  14.             'filter'=>Lookup::items('PostStatus'),
  15.         ),
  16.         'create_time',
  17.         'author_id',
  18.         array(
  19.             'class'=>'CButtonColumn',
  20.         ),
  21.     ),
  22. )); ?>
  23.  
  24.  
  25. and i replaced 'author_id' with ,
  26.         array(
  27.             'name'=>'author_id',
  28.             'value'=>Lookup::usernme($model->author->id),
  29.             )
  30.  
  31. by writing a function in lookup class like this,
  32.  
  33.  public static function usernme($userid)
  34.     {
  35.    
  36.      $name = User::model()->findByPk($userid);
  37.      $nme = $name->username;
  38.      
  39.      return $nme;
  40.        
  41.     }
  42.  
  43.  
  44.  
  45. i tried with array('name'=>'author_id', 'value'=>$model->author->username) which didnt worked 4 me
Advertisement
Add Comment
Please, Sign In to add comment