A
A
agent11562016-09-10 12:23:55
Yii
agent1156, 2016-09-10 12:23:55

Yii2 actionDelete method not working, why?

How to delete in CRUD?
I go to the admin panel, shows a list from the database. View works update works, I click on fish and bad request (#400) pops up WHY ?
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
agent1156, 2016-09-10
@agent1156

public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST','GET'],
],
] ,
];
}

M
Maxim Timofeev, 2017-02-01
@webinar

Bad Request (#400): Unable to verify your data submission Indicates
that you are sending a post request that does not contain a csrf token. It is necessary to either disable the check or add it to the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question