1
如何在我的gridview中查看動作,我已經有我的數據和視圖按鈕的列表,但我想單擊該視圖按鈕時看到不同的記錄。現在我只看到錯誤,並且我的網址更改爲/ index/0或/ index/1等記錄的ID。在gridview中創建視圖動作
<?php
use yii\grid\GridView;
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'ID'=>'id',
'Title'=>'post_title',
'Text'=>'post_text',
'Author'=>'name',
[
'class' => 'yii\grid\ActionColumn',
'header'=>'Действия',
'headerOptions' => ['width' => '80'],
'template' => '{view}',
],
],
'rowOptions' => function ($model, $key, $index, $grid) {
return ['id' => $model['id']];
},
]); ?>
我有一個錯誤:
An Error occurred while handling another error:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/error' in W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Controller.php:125
Stack trace:
#0 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Module.php(454): yii\base\Controller->runAction('error', Array)
#1 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\web\ErrorHandler.php(93): yii\base\Module->runAction('site/error')
#2 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\ErrorHandler.php(109): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#4 {main}
Previous exception:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/view' in W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Controller.php:125
Stack trace:
#0 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Module.php(454): yii\base\Controller->runAction('view', Array)
#1 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\web\Application.php(100): yii\base\Module->runAction('site/view', Array)
#2 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#3 W:\XAMPP\htdocs\test\basic\index.php(12): yii\base\Application->run()
#4 {main}
Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\web\Application.php:112
Stack trace:
#0 W:\XAMPP\htdocs\test\basic\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 W:\XAMPP\htdocs\test\basic\index.php(12): yii\base\Application->run()
#2 {main}
如果出現錯誤,應在該問題中包含該錯誤。 –
當然,我有錯誤,我的控制器不處理url像http:// localhost/basic/site/0 – Rosti