/** * Generates the button dropdown. * @return string the rendering result. */ protected function renderButton() { Html::addCssClass($this->options, '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, 'dropdown-toggle'); $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, 'dropdown-toggle'); $options['data-toggle'] = 'dropdown'; $splitButton = ''; } return Button::widget(['tagName' => $this->tagName, 'label' => $label, 'options' => $options, 'encodeLabel' => false, 'view' => $this->getView()]) . "\n" . $splitButton; }
/** * 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)) { if (isset($button['dropdown'])) { $option = array_merge($button['dropdown'], ['view' => $this->getView()]); $buttons[] = ButtonDropdown::widget($option); } else { $label = ArrayHelper::getValue($button, 'label'); $options = ArrayHelper::getValue($button, 'options'); $buttons[] = Button::widget(['label' => $label, 'options' => $options, 'encodeLabel' => $this->encodeLabels, 'view' => $this->getView()]); } } else { $buttons[] = $button; } } return implode("\n", $buttons); }
use yii\adminUi\widget\ButtonGroup; use yii\adminUi\widget\Button; use common\modules\media\widgets\MediaUpload; use common\modules\media\widgets\EmbedUpload; /* @var $this yii\web\View */ /* @var $model common\models\Asset */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="asset-form"> <?php $mediaupload = MediaUpload::widget(['options' => ['addRemoveLinks' => true]]); $embedupload = EmbedUpload::widget(); Row::begin(); Column::begin(['grid' => [['type' => Column::TYPE_DESKTOP, 'size' => Column::SIZE_FULL]]]); echo ButtonGroup::widget(['buttons' => [Button::widget(['label' => 'Media Upload', 'options' => ['class' => 'btn-primary btn-lg col-xs-6 col-sm-6 col-md-6 col-lg-6', 'data-toggle' => "collapse", 'data-target' => '#media-upload', 'data-parent' => "#media-upload-wrapper"]]), Button::widget(['label' => 'Embed Media Upload', 'options' => ['class' => 'btn-info btn-lg col-xs-6 col-sm-6 col-md-6 col-lg-6', 'data-toggle' => "collapse", 'data-target' => '#embed-upload', 'data-parent' => "#media-upload-wrapper"]])], 'options' => ['class' => 'col-md-12']]); Column::end(); Row::end(); Row::begin(); Column::begin(['grid' => [['type' => Column::TYPE_DESKTOP, 'size' => Column::SIZE_FULL]]]); echo Collapse::widget(['box' => false, 'header' => false, 'options' => ['id' => 'media-upload-wrapper'], 'items' => [['content' => $mediaupload, 'contentOptions' => ['id' => 'media-upload']], ['content' => $embedupload, 'contentOptions' => ['id' => 'embed-upload']]]]); Column::end(); Row::end(); /* echo MediaUpload::widget([ 'options' => [ 'addRemoveLinks' => true, ] ]); //*/ ?>