-
Notifications
You must be signed in to change notification settings - Fork 1
/
ButtonGroup.php
68 lines (56 loc) · 1.5 KB
/
ButtonGroup.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
67
68
<?php
namespace iutbay\yii2bootstrap;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/**
* ButtonGroup widget
* @author Kevin LEVRON <[email protected]>
*/
class ButtonGroup extends \yii\bootstrap\ButtonGroup
{
/**
* Button group size
* @var string
*/
public $size;
/**
* Buttons type
* @var string
*/
public $type;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!empty($this->size)) {
Html::addCssClass($this->options, 'btn-group-' . $this->size);
}
}
/**
* Generates the buttons that compound the group as specified on [[buttons]].
* @return string the rendering result.
*/
protected function renderButtons()
{
$buttons = [];
foreach ($this->buttons as $button) {
if (is_array($button)) {
$visible = ArrayHelper::remove($button, 'visible', true);
if ($visible === false) {
continue;
}
$button['view'] = $this->getView();
if (!isset($button['encodeLabel'])) {
$button['encodeLabel'] = $this->encodeLabels;
}
if (!empty($this->type) && !isset($button['type'])) $button['type'] = $this->type;
$buttons[] = Button::widget($button);
} else {
$buttons[] = $button;
}
}
return implode("\n", $buttons);
}
}