forked from 2amigos/yii2-bootstrap-form-helpers-library
/
Select.php
52 lines (46 loc) · 1.27 KB
/
Select.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
<?php
/**
* @copyright Copyright (c) 2013 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\formhelpers;
use yii\helpers\Html;
/**
* \dosamigos\formhelpers\Select renders the Select Bootstrap Form helper.
*
* @see http://bootstrapformhelpers.com/select/#jquery-plugins
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\formhelpers
*/
class Select extends InputWidget
{
/**
* @var array the array keys are option values, and the array values
* are the corresponding option labels.
*/
public $items = [];
/**
* @inheritdoc
*/
public function init()
{
Html::addCssClass($this->options, 'bfh-selectbox');
parent::init();
}
/**
* @inheritdoc
*/
public function run()
{
$input[] = Html::beginTag('div', $this->options);
foreach ($this->items as $key => $value) {
$input[] = Html::tag('div', (string)$value, ['data-value' => (string)$key]);
}
$input[] = Html::endTag('div');
echo implode("\n", $input);
$this->registerPlugin('bfhselectbox');
}
}