Esempio n. 1
0
 /**
  * Retrieves items tag
  * @param array $item given parent item
  * @return Dropdown widget
  */
 private function _getDropdownTag($item)
 {
     $dropdownType = ArrayHelper::getValue($item, 'dropdownType', self::TYPE_DEFAULT);
     $items = ArrayHelper::getValue($item, 'items', null);
     if ($items !== null && is_array($items)) {
         if ($dropdownType === self::TYPE_DEFAULT || $dropdownType === self::TYPE_USER) {
             $options = ['class' => 'dropdown-menu-default'];
         } else {
             $options = ['class' => sprintf('%s %s', 'dropdown-menu-default extended', $dropdownType)];
         }
         $items = Dropdown::widget(['title' => ArrayHelper::getValue($item, 'title', ''), 'more' => ArrayHelper::getValue($item, 'more', []), 'scroller' => ArrayHelper::getValue($item, 'scroller', []), 'items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'options' => $options]);
     }
     return $items;
 }
 /**
  * Renders the dropdown
  * @return string the rendering result
  */
 protected function renderDropdown()
 {
     $config = $this->dropdown;
     $config['clientOptions'] = false;
     return Dropdown::widget($config);
 }
Esempio n. 3
0
 /**
  * Renders tab items as specified on [[items]].
  * @return string the rendering result.
  * @throws InvalidConfigException.
  */
 protected function renderItems()
 {
     $headers = [];
     $panes = [];
     if (!$this->hasActiveTab() && !empty($this->items)) {
         $this->items[0]['active'] = true;
     }
     foreach ($this->items as $n => $item) {
         if (!isset($item['label'])) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
         $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', []));
         if (isset($item['items'])) {
             if ($this->styled) {
                 throw new InvalidConfigException("The 'styled' not support dropdown items. Please, set 'styled' to false.");
             }
             $label .= ' <b class="caret"></b>';
             Html::addCssClass($headerOptions, 'dropdown');
             if ($this->renderDropdown($item['items'], $panes)) {
                 Html::addCssClass($headerOptions, 'active');
             }
             $header = Html::a($label, "#", ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false]);
         } elseif (isset($item['content'])) {
             $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
             $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n);
             Html::addCssClass($options, 'tab-pane');
             if (ArrayHelper::remove($item, 'active')) {
                 Html::addCssClass($options, 'active');
                 Html::addCssClass($headerOptions, 'active');
             }
             $header = Html::a($label, '#' . $options['id'], ['data-toggle' => 'tab']);
             $panes[] = Html::tag('div', $item['content'], $options);
         } else {
             throw new InvalidConfigException("Either the 'content' or 'items' option must be set.");
         }
         $headers[] = Html::tag('li', $header, $headerOptions);
     }
     $headers = Html::tag('ul', implode("\n", $headers), $this->options);
     $panes = Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']);
     return $this->placement == self::PLACEMENT_BELOW ? $panes . "\n" . $headers : $headers . "\n" . $panes;
 }