/** * Generates the dropdown menu. * * @return string the rendering result. */ protected function renderDropdown() { $buttons = []; foreach ($this->buttons as $key => $button) { $options = $this->options; unset($options['id']); $url = $this->createUrl($this->key, $key); $label = $this->encodeLabels ? Html::encode($button['label']) : $button['label']; $buttons[] = ['label' => isset($button['icon']) ? Html::icon($button['icon'], ['class' => 'text-' . $button['type']]) . ' ' . $label : $label, 'url' => $url, 'linkOptions' => $options]; } if (count($buttons) <= 1) { return ''; } $splitButton = Button::widget(['label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => ['data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'class' => 'btn-default dropdown-toggle btn-xs']]); return $splitButton . "\n" . Dropdown::widget(['items' => $buttons, 'encodeLabels' => false, 'options' => ['class' => 'pull-right']]); }
/** * Creates a prepend content. * * @param \yii\db\ActiveRecord $model the data model * @param mixed $key the key associated with the data model * @param integer $index the current row index * @return string the created prepend content */ public function getPrependContent($model, $key, $index) { if ($this->prepend === '') { return Html::a(Html::encode($model->{$this->attribute}), [$this->controller ? $this->controller . '/' . 'update' : 'update', 'id' => $key], ['data-pjax' => 0, 'class' => 'rk-row-title']); } else { return $this->prepend instanceof Closure ? call_user_func($this->prepend, $model, $key, $index) : $this->prepend; } }