Hi. I have problem with routing urls. This is my configuration:
'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>',
'admin/useredit/<id:\d+>'=>'admin/useredit',
),
'showScriptName'=>false,
'urlSuffix'=>'.html',
),
When I use
$this->createUrl('admin/useredit',array('id'=>'2'))
then is creating this url:
xxx.com/admin/useredit/.html2 but I expecting xxx.com/admin/useredit/2.html
What’s wrong?
konapaz
(Konapaz)
2
Hi
temporary set ‘showScriptName’=>true, and check what is the generated url
Generated url: xxx.com/index.php/admin/useredit/.html2
I noticed the problem is only in CGridView. I have following code:
...
'value' => 'CHtml::link("$data->username","'.$this->createUrl('admin/useredit',array('id'=>$data->id)).'".CHtml::encode($data->id))',
...
konapaz
(Konapaz)
4
what is the CHtml::encode($data->id)) ?
I think you have to try
'CHtml::link($data->username,"'.$this->createUrl('admin/useredit',array('id'=>$data->id)).'")',