2017-07-15 6 views
0

je code suivant pour l'affichage d'une vue sur la grille, mais je reçois grand avis de php comme suit:Je reçois erreur sur Yii CGridView

$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']); 

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'image-grid', 
'dataProvider'=>$model->search(), 
'filter'=>$model, 
'columns'=>array(
    'image_id', 
    array(
     'name'=>'file_path', 
     'filter'=>'', 
     'value'=>'CHtml::image($data->getImgThumb($data->file_path,99,66, false, $data->image_id))', 
     'type'=>'raw', 
    ), 
    'DateCreated', 
    'uploaded_on', 
    'updated_on', 
    array(
     'name'=>'user_id', 
     'filter' => CHtml::listData(User::model()->findAll(array('order'=>'full_name')), 'id', 'dropDownUser'), 
     'value'=>'($data->user_id)? $data->user->full_name." (".$data->user->user_name.")" : ""', 
    ), 
    array(
     'name'=>'Title', 
     'value'=> 'stripslashes(substr($data["Title"], 0, 200))."..."', 
    ), 
    'download_count', 
), 
)); 

Et les erreurs suivantes: /home/drikimages/cadre /base/CComponent.php(606): eval() 'd code (1)

Trace de pile: /home/drikimages/framework/base/CComponent.php(606): eval()

/home/drikimages/framework/zii/widgets/grid/CDataColumn.php(131): CComponent->evaluateExpression("($data->user_id)? $data->user->full_name." (".$data->user->user_...", array("data" => Image, "row" => 0)) 

Répondre

0

Essayez ceci

class model extends CActiveRecord 
{ 
    // .. 

    // .. 


    public function GetUser_display_name() 
    { 
     if($this->user_id && isset($this->user)) 
      return $this->user->full_name . " (" . $this->user->user_name . ")"; 
    } 

} 


// in zii.widgets.grid.CGridView column array 

array(
    'name'=>'user_id', 
    'filter' => CHtml::listData(User::model()->findAll(array('order'=>'full_name')), 'id', 'dropDownUser'), 
    'value'=>'$data->user_display_name', 
),