yii2删除记录报错
yii2 delete record error
我在删除所有记录时出错 table:
An Error occurred while handling another error:
exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to perform this action.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\AccessControl.php:151
Stack trace:
Previous exception:
exception 'yii\web\MethodNotAllowedHttpException' with message 'Method Not Allowed. This url can only handle the following request methods: POST.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\VerbFilter.php:105
Stack trace:
_
这是我的控制器:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
和我在 view.php
中的删除按钮
<?= Html::a('Delete', ['delete', 'id' => $model->id_transaksi], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
])
?>
当我用 GET 替换 POST 时它工作,但警报确认不工作..
你知道怎么了吗?请帮忙
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],//not POST
],
],
];
}
错别字,希望对你有帮助
ref.link
http://www.yiiframework.com/doc-2.0/yii-filters-verbfilter.html
可能是您收到了错误信息
Method Not Allowed. This url can only handle the following request methods: POST.
因为浏览器以某种方式重新加载请求的页面 url。当您单击 link 删除该模型时,请求方法是 POST,因为它是指定的。那时发生了一些异常(似乎与访问规则有关),使您的浏览器原谅了请求方法。
我在删除所有记录时出错 table:
An Error occurred while handling another error:
exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to perform this action.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\AccessControl.php:151
Stack trace:
Previous exception:
exception 'yii\web\MethodNotAllowedHttpException' with message 'Method Not Allowed. This url can only handle the following request methods: POST.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\VerbFilter.php:105
Stack trace:
_
这是我的控制器:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
和我在 view.php
中的删除按钮<?= Html::a('Delete', ['delete', 'id' => $model->id_transaksi], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
])
?>
当我用 GET 替换 POST 时它工作,但警报确认不工作..
你知道怎么了吗?请帮忙
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],//not POST
],
],
];
}
错别字,希望对你有帮助 ref.link http://www.yiiframework.com/doc-2.0/yii-filters-verbfilter.html
可能是您收到了错误信息
Method Not Allowed. This url can only handle the following request methods: POST.
因为浏览器以某种方式重新加载请求的页面 url。当您单击 link 删除该模型时,请求方法是 POST,因为它是指定的。那时发生了一些异常(似乎与访问规则有关),使您的浏览器原谅了请求方法。