Answer the question
In order to leave comments, you need to log in
data-method="post" not working?
in the common/widget folder, a header widget was created where there is this code
<li><a href="<?= Yii::$app->urlManager->createUrl(['/site/logout']) ?>" data-method="post" ><i class="fa fa-sign-out"></i><?=Yii::t('app','LOGOUT');?></a></li>
<?= Html::a('<i class="fa fa-sign-out"></i>'.Yii::t('app','LOGOUT'),Url::to(['/site/logout']),['data-method'=>'post']); ?>
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
...
];
public $js = [
...
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace frontend\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class IndexAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
...
];
public $js = [
...
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
Answer the question
In order to leave comments, you need to log in
Example from advanced: https://github.com/yiisoft/yii2-app-advanced/blob/...
You must have a form to make a post request.
See how it looks in the advanced application after rendering (open the page and ctrl+u, see what html is generated by this php code in the source code).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question