Reputation: 135
In a cell of a dataColumn in gridView i've placed a link with data-method = post, and a data-confirm = 'Some confirm vessage'. But when you click the link it works with get method, and no confirm message is displayed. Why it does not work? Here is the code:
<?= 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',
]
);
}
],
]); ?>
If i place the Html::a outside the gridView it works fine. Am i doing somthing wrong?
Upvotes: 2
Views: 1489
Reputation: 1089
Your 'format' property of data cell needs to be 'raw' in this case, as 'html' filters out a lot of stuff.
<?= 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',
]
);
}
],
]); ?>
Upvotes: 6