I'm using the CGridView
to display a data table:
/application/protected/views/foo/bar.php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'my-grid',
'dataProvider' => $dataProvider,
'filter' => $model,
'columns' => array(
'myid',
...
array(
'class' => 'CButtonColumn',
),
),
));
That created a table with three links for each row: view
, update
, and delete
; e.g. (for the view
): /index.php/foo/123
, where 123
is the ID (or primary key value) of the element.
Now I want to modify the widget call, in order to get different buttons links like /index.php/bar/123
:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'my-grid',
'dataProvider' => $dataProvider,
'filter' => $model,
'columns' => array(
'myid',
...
array(
'class' => 'CButtonColumn',
'template' => '{view}{update}{delete}',
'buttons' => array(
'view' => array(
'url' => 'Yii::app()->createUrl("bar", array("myid" => $data->myid))',
)
),
),
),
));
The (view) link I'm getting looks like this: /index.php/bar/myid/123
-- and the request ends with a 404
error.
How to build links without the parameter name in the URL?
Additional info -- my routing configuration in the /application/protected/config/main.php
:
return array(
...
'components'=>array(
...
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
...
),
);
In /protected/config/main.php
Change Action View As