Answer the question
In order to leave comments, you need to log in
Yii2 data-method=post not working?
Can't figure it out already broke my head in view template in widgets Nav added
['label' => 'Выйти', 'url' => ['/core/default/logout'], 'linkOptions' => ['data-method' => 'post'], 'visible' => !\Yii::$app->user->isGuest],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
exception 'yii\web\MethodNotAllowedHttpException' with message 'Method Not Allowed. This url can only handle the following request methods: POST.' in D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\filters\VerbFilter.php:105
Stack trace:
#0 [internal function]: yii\filters\VerbFilter->beforeAction(Object(yii\base\ActionEvent))
#1 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\base\Component.php(538): call_user_func(Array, Object(yii\base\ActionEvent))
#2 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\base\Controller.php(259): yii\base\Component->trigger('beforeAction', Object(yii\base\ActionEvent))
#3 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\web\Controller.php(108): yii\base\Controller->beforeAction(Object(yii\base\InlineAction))
#4 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\base\Controller.php(149): yii\web\Controller->beforeAction(Object(yii\base\InlineAction))
#5 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('logout', Array)
#6 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\web\Application.php(83): yii\base\Module->runAction('core/default/lo...', Array)
#7 D:\_osweb_premium\domains\***\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#8 D:\_osweb_premium\domains\***\web\index.php(18): yii\base\Application->run()
#9 {main}
Answer the question
In order to leave comments, you need to log in
How to enable YiiAssets I tried to write in detail toproduction.ru/blog/yii2-data-method-post.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question