-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionColumn.php
executable file
·66 lines (62 loc) · 2.11 KB
/
ActionColumn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace makroxyz\materializecss;
use Yii;
/**
* Class ActionColumn
* @package makroxyz\materializecss
*/
class ActionColumn extends \yii\grid\ActionColumn
{
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->initDefaultButtons();
}
/**
* Initializes the default button rendering callbacks.
*/
protected function initDefaultButtons()
{
if (!isset($this->buttons['view'])) {
$this->buttons['view'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'View'),
'aria-label' => Yii::t('yii', 'View'),
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a(Icon::widget([
'name' => 'visibility',
]), $url, $options);
};
}
if (!isset($this->buttons['update'])) {
$this->buttons['update'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'Update'),
'aria-label' => Yii::t('yii', 'Update'),
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a(Icon::widget([
'name' => 'edit',
]), $url, $options);
};
}
if (!isset($this->buttons['delete'])) {
$this->buttons['delete'] = function ($url, $model, $key) {
$options = array_merge([
'title' => Yii::t('yii', 'Delete'),
'aria-label' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
'data-method' => 'post',
'data-pjax' => '0',
], $this->buttonOptions);
return Html::a(Icon::widget([
'name' => 'delete',
]), $url, $options);
};
}
}
}