コード例 #1
0
 /**
  * Generates the button dropdown.
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     Html::addCssClass($this->options, ['widget' => 'btn']);
     $label = $this->label;
     if ($this->encodeLabel) {
         $label = Html::encode($label);
     }
     if ($this->split) {
         $options = $this->options;
         $this->options['data-toggle'] = 'dropdown';
         Html::addCssClass($this->options, ['toggle' => 'dropdown-toggle']);
         unset($this->options['id']);
         $splitButton = Button::widget(['label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $this->options, 'view' => $this->getView()]);
     } else {
         $label .= ' <span class="caret"></span>';
         $options = $this->options;
         if (!isset($options['href'])) {
             $options['href'] = '#';
         }
         Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
         $options['data-toggle'] = 'dropdown';
         $splitButton = '';
     }
     return Button::widget(['tagName' => $this->tagName, 'label' => $label, 'options' => $options, 'encodeLabel' => false, 'view' => $this->getView()]) . "\n" . $splitButton;
 }
コード例 #2
0
 /**
  * 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;
             }
             $buttons[] = Button::widget($button);
         } else {
             $buttons[] = $button;
         }
     }
     return implode("\n", $buttons);
 }