Example #1
0
 /**
  * Executes the widget.
  */
 public function run()
 {
     Html::addCssClass($this->inputOptions, 'spinner-input form-control');
     $this->buttonsConfig = array_merge(['label' => ''], $this->buttonsConfig);
     if ($this->hasModel()) {
         $input = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
     } else {
         $input = Html::textInput($this->name, $this->value, $this->inputOptions);
     }
     if ($this->buttonsLocation == self::BUTTONS_LOCATION_VERTICAL) {
         $this->buttonsConfig = array_merge($this->buttonsConfig, ['size' => Button::SIZE_MINI]);
     }
     $btnUp = Button::widget(array_merge($this->buttonsConfig, ['icon' => 'fa fa-angle-up', 'options' => ['class' => 'spinner-up']]));
     $btnDown = Button::widget(array_merge($this->buttonsConfig, ['icon' => 'fa fa-angle-down', 'options' => ['class' => 'spinner-down']]));
     if ($this->buttonsLocation == self::BUTTONS_LOCATION_VERTICAL) {
         $spinner = $input . Html::tag('div', $btnUp . $btnDown, ['class' => 'spinner-buttons input-group-btn btn-group-vertical']);
     } else {
         $spinner = Html::tag('div', $btnUp . $input . $btnDown, ['class' => 'spinner-buttons input-group-btn']);
     }
     echo Html::tag('div', Html::tag('div', $spinner, ['class' => 'input-group input-' . $this->size]), $this->options);
     SpinnerAsset::register($this->view);
     $this->registerPlugin('spinner');
 }
Example #2
0
 public function init()
 {
     $view = $this->getView();
     SpinnerAsset::register($view);
 }