Question

I'm a newbie of Yii and now I have a link:

localhost/qr/delete/33

I dont' know how to make it as

localhost/qr-code/delete/33

using urlManager in main.php.

Was it helpful?

Solution 2

If qr is controller , delete is action and 33 is id, then here is your solution .

   rules = array(
      '<controller:(qr)>-code/delete/<id:\d+>'=>'<controller>/delete',

      '<controller:\w+>/<id:\d+>' => '<controller>/view',
      '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
      '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
   ),

OTHER TIPS

Should be able to add this to your array in your config:

'qr-code/<action:\w+>/<id:\d+>' => 'qr/<action>',
//other rules here

This will make it so that delete or update actions can work. Make sure you put this before other rules so that it has a higher priority. id will be passed as a variable to your action in your qr controller

public function actionDelete($id) {
    //your code here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top