0

I have zii.widgets.grid.CGridView and I applied to it a CActiveDataProvider from different model, for example:

In the users model I used zii.widgets.grid.CGridView to display the articles that the user created, so when the user clicks on view, update, delete buttons, he should go to the articles controller actions, not to the users controller.

Here is my code:

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'articles-grid',
    'dataProvider'=>$ar,
    'filter'=>$articles,
    'columns'=>array(
                'title',
                'category',
                'display',
                'priority',
                'newsBanner',
                'idUser',
                'date',
        array(
            'class'=>'CButtonColumn',
                     'viewButtonUrl' =>"Yii::app()->createUrl('articles\view', array('id'=>'idUser'))"
        ),
    ),
));

the idUser that used in the url should be the same value as the idUser that used in the columns array in the widget, so how I can do that?

lin
  • 17,956
  • 4
  • 59
  • 83
MD.MD
  • 708
  • 4
  • 14
  • 34

1 Answers1

1

you need to change

'viewButtonUrl' =>"Yii::app()->createUrl('articles\view', array('id'=>'idUser'))"

to

'viewButtonUrl' =>'Yii::app()->createUrl("articles/view", array("id"=>"$data->idUser"))'

Note:-

I have changed idUser to $data->idUser

Let me see
  • 5,063
  • 9
  • 34
  • 47