當我想刪除GridView的一個項目我得到這個錯誤:yii2當刪除的GridView:無法驗證數據提交
exception 'yii\web\BadRequestHttpException' with message 'Unable to verify your data submission.
我這是我的控制器代碼:
class DevisController extends Controller
{
public $layout = 'lay-admin';
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/* ..... */
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
當我將post方法更改爲行爲函數中的get方法我得到此錯誤
Method Not Allowed. This url can only handle the following request methods: GET.
GridView代碼:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'idDevis',
'reference',
'client',
'dateCreation',
'contact',
'valableJusqua',
'dateRelance',
[
'attribute'=>'etat',
'filter'=>ArrayHelper::map(Devis::find()->asArray()->all(), 'etat', 'etat'),
],
'commercial',
'modePaiement',
'delaiPaiement',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
任何想法請!
您的視圖中是否存在CSRF參數? – Bizley
我不認爲,我看不到這個參數 –
現在我得到這個錯誤'方法不允許。這個URL只能處理下面的請求方法:POST.' –