This code <?php echo Url::to(['/tasks/', 'view' => $task->id]);?>
transforms into the url web/tasks?view=1 what code and where will transform output variants into the web/tasks/view/1?
Asked
Active
Viewed 29 times
1
-
With little research you can find this: https://www.yiiframework.com/doc/guide/2.0/en/runtime-routing, this should help you understand the principles – Serghei Leonenco Jul 01 '22 at 02:50
1 Answers
0
Config File:
'urlManager' => [
# code...
'rules' => [
'tasks/view/<id:\d+>' => 'tasks/view',
],
Controller-Action
public function actionView($id) {
// $_GET or \Yii::$app->getRequest()->GET('id')
$id = ... int id
# code..
}
View File:
<?php echo Url::to(['/tasks/view', 'id' => $task->id]);?>

user206
- 1,085
- 1
- 10
- 15