gpt4 book ai didi

gridview - Yii2 数据方法帖子在 gridView 中不起作用

转载 作者:行者123 更新时间:2023-12-02 20:15:05 24 4
gpt4 key购买 nike

在 gridView 中的 dataColumn 的单元格中,我放置了一个带有 data-method = post 的链接,以及 data-confirm = 'Some verify vessage'。但是,当您单击该链接时,它会使用 get 方法,并且不会显示确认消息。为什么它不起作用?这是代码:

<?= GridView::widget([
'dataProvider' => new ArrayDataProvider([
'allModels' => $model->orders
]),
'columns' => [
//... some other columns .... Then:
[
'headerOptions' => ['class' => 'bg-teal color-palette'],
'footerOptions' => ['class' => 'bg-teal color-palette'],
'format' => 'html',
'value' => function($model)
{
return Html::a(
'Delete',
[
'order/delete',
'id' => $model->id
],
[
'class' => 'btn btn-primary btn-block',
'data-confirm' => 'Do you realy want to delete the item?',
'data-method' => 'post',
]
);
}
],
]); ?>

如果我将 Html::a 放在 gridView 之外,它就可以正常工作。我做错了什么吗?

最佳答案

在这种情况下,数据单元格的“格式”属性需要是“原始”,因为“html”会过滤掉很多内容。

<?= GridView::widget([
'dataProvider' => new ArrayDataProvider([
'allModels' => $model->orders
]),
'columns' => [
//... some other columns .... Then:
[
'headerOptions' => ['class' => 'bg-teal color-palette'],
'footerOptions' => ['class' => 'bg-teal color-palette'],
'format' => 'raw',
'value' => function($model) {
return Html::a(
'Delete',
[
'order/delete',
'id' => $model->id
],
[
'class' => 'btn btn-primary btn-block',
'data-confirm' => 'Do you realy want to delete the item?',
'data-method' => 'post',
]
);
}
],
]); ?>

关于gridview - Yii2 数据方法帖子在 gridView 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39772943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com