删除不起作用方法不允许(#405)gridview yii2

Noo*_*ict 5 jquery yii2 yii2-advanced-app yii2-basic-app

这是我的网格视图,我从类更改actionColumn为:

[   'format' => 'html',
            'contentOptions'=>['style'=>'width: 5px;'],
            'value' => function($model) {
                if($model->id == Yii::$app->user->identity->id) {
                    return  Html::a('<i class="glyphicon glyphicon-share-alt"></i>').' '. 
                            Html::a('<i class="glyphicon glyphicon-pencil"></i>', ['update', 'id' => $model->id]).' '.
                            Html::a('<i class="glyphicon glyphicon-trash"></i>', ['delete', 'id' => $model->id], ['data' => ['confirm' => 'Do you really want to delete this element?','method' => 'post']]);
                }
                return '';
            },
        ],
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误。

Method Not Allowed (#405)

Method Not Allowed. This url can only handle the following request methods: POST. 
Run Code Online (Sandbox Code Playgroud)

当我actionColumn再次更改它时,它可以正常工作,但是我更改了代码,这只是给我一个错误。

soj*_*oju 4

由于html格式化程序将使用HtmlPurifier清理值,因此您只需将格式更改为.raw

阅读更多:http ://www.yiiframework.com/doc-2.0/guide-output-formatter.html#other-formatters