1
如何在我的GridView中的任何行項目上添加URL鏈接?Yii Framework GridView函數
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'email:email',
'vat_code',
'code',
'company',
'country',
'city',
'address',
'phone',
'name',
['class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'buttons' => ['update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update', 'id' => substr($url, strpos($url, 'id=')+3, strlen($url)), 'type' => substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], 'user/')+5, 8)]);
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('app', 'Update'),]);
},
'delete' => function ($url, $type) {
$url = Yii::$app->urlManager->createUrl(['user/delete', 'id' => substr($url, strpos($url, 'id=')+3, strlen($url)), 'type' => substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], 'user/')+5, 8)]);
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('app', 'Delete'),]);
}],
],
],
]); ?>
我需要在電子郵件行上具有與鉛筆圖標動作列相同的編輯URL。我使用Yii 2.0版本。
我試圖執行它是這樣的:Add column as link in CGridView 但沒有運氣。
非常感謝你! – The50
答覆已更新..希望是有用的 – scaisEdge