本文整理汇总了PHP中yii\bootstrap\ButtonDropdown类的典型用法代码示例。如果您正苦于以下问题:PHP ButtonDropdown类的具体用法?PHP ButtonDropdown怎么用?PHP ButtonDropdown使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ButtonDropdown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testContainerOptions
public function testContainerOptions()
{
$containerClass = "dropup";
ButtonDropdown::$counter = 0;
$out = ButtonDropdown::widget(['containerOptions' => ['class' => $containerClass], 'label' => 'Action', 'dropdown' => ['items' => [['label' => 'DropdownA', 'url' => '/'], ['label' => 'DropdownB', 'url' => '#']]]]);
$this->assertContains("{$containerClass} btn-group", $out);
}
示例2: renderPerPageSelector
public function renderPerPageSelector()
{
$page_count = $this->pagination->getPageCount();
if ($page_count < 2 && $this->hideOnSinglePage) {
return '';
}
$current_page_size = $this->pagination->getPageSize();
list($min_page_size, $max_page_size) = $this->pagination->pageSizeLimit;
if ($min_page_size < 10) {
$min_page_size = 10;
}
$items = [];
$_max_page_size = $max_page_size > 50 ? 50 : $max_page_size;
$per_page_items = range($min_page_size, $_max_page_size, 10);
if ($max_page_size >= 100) {
$_max_page_size = $max_page_size > 500 ? 500 : $max_page_size;
$_per_page_items = range(100, $_max_page_size, 100);
$per_page_items = array_merge($per_page_items, $_per_page_items);
}
if ($max_page_size >= 1000) {
$_per_page_items = range(1000, $max_page_size, 1000);
$per_page_items = array_merge($per_page_items, $_per_page_items);
}
foreach ($per_page_items as $per_page_item) {
$items[] = ['label' => $per_page_item, 'url' => $this->pagination->createUrl(0, $per_page_item), 'active' => $per_page_item == $current_page_size, 'linkOptions' => $this->linkOptions];
}
$dropdown = ButtonDropdown::widget(['options' => ['class' => 'btn-default'], 'label' => $current_page_size, 'dropdown' => ['items' => $items]]);
$content = __('Total items: <b>{items}</b>', ['items' => $this->pagination->totalCount]);
$content .= ' / ' . $dropdown;
$content = Html::tag('div', $content);
echo Html::tag('div', $content, ['class' => 'pagination-per-page']);
}
示例3: run
public function run()
{
$languages = $this->languages;
$current = $languages[Yii::$app->language];
unset($languages[Yii::$app->language]);
$items = [];
foreach ($languages as $code => $language) {
$temp = [];
$temp['label'] = $language;
$temp['url'] = Url::current(['language' => $code]);
array_push($items, $temp);
}
echo ButtonDropdown::widget(['label' => $current, 'dropdown' => ['items' => $items], 'containerOptions' => $this->container, 'options' => ['class' => 'btn btn-xs btn-warning', 'style' => 'margin-top: 1px;'], 'tagName' => 'button']);
}
示例4: init
/**
* Inits ButtonDropdown
*/
public function init()
{
parent::init();
$this->options['data-toggle'] = 'dropdown';
if ($this->hover === true) {
$this->options['data-hover'] = 'dropdown';
}
if ($this->encodeLabel) {
$this->label = Html::encode($this->label);
}
$this->options['data-close-others'] = 'true';
Html::addCssClass($this->options, 'btn');
Html::addCssClass($this->options, 'dropdown-toggle');
}
示例5: run
public function run()
{
$languages = $this->languages;
$current = $languages[Yii::$app->language];
unset($languages[Yii::$app->language]);
$items = [];
foreach ($languages as $code => $language) {
$temp = [];
$temp['label'] = $language;
$temp['url'] = Url::current(['language' => $code]);
array_push($items, $temp);
}
echo ButtonDropdown::widget(['label' => $current, 'dropdown' => ['items' => $items]]);
}
示例6: run
public function run()
{
$items = [];
$currentUrl = preg_replace('/' . $this->currentLang->code . '+(\\/*)/', '', Yii::$app->getRequest()->getUrl(), 1);
foreach ($this->allLanguages->code as $key => $language) {
$temp = [];
/* Добавление языковой приставки только к второстепенным языкам */
if ($language !== Yii::$app->sourceLanguage || Yii::$app->getUrlManager()->displaySourceLanguage) {
$url = '/' . $key . $currentUrl;
} else {
$url = $currentUrl;
}
if (Yii::$app->language !== $language) {
$temp['label'] = $this->allLanguages->title[$key];
$temp['url'] = $url;
array_push($items, $temp);
//$item = ['label' => $language['name'], 'url' => $url];
}
}
echo ButtonDropdown::widget(['label' => $this->currentLang->title, 'dropdown' => ['items' => $items]]);
}
示例7: getLinks
public function getLinks($parent)
{
$links = \common\models\main\Links::find()->innerJoinWith('category')->where(['categories_id' => $this->categories_id])->andWhere(['categories.visible' => 1])->andWhere(['parent' => $parent])->orderBy(['seq' => SORT_ASC])->all();
if (!$links) {
return '<em class="text-muted">Ссылки не добавлены</em>';
}
$html = Html::beginTag('ul', ['class' => 'list-unstyled']);
/**
* @var $i
* @var $link \common\models\main\Links
*/
foreach ($links as $i => $link) {
$html .= Html::tag('li', Html::beginTag('div', ['class' => 'row']) . Html::tag('div', Html::a($link->anchor, ['/map/content', 'links_id' => $link->id], ['style' => ($link->state == 0 ? 'text-decoration: line-through; color: #aaa;' : '') . (Yii::$app->request->get('links_id') == $link->id || Yii::$app->request->get('parent_links_id') == $link->id ? 'font-weight: bold;' : '')]), ['class' => 'col-sm-9']) . Html::tag('div', ButtonDropdown::widget(['label' => '<i class="fa fa-cog"></i>', 'dropdown' => ['items' => [['label' => 'Параметры', 'url' => ['/map/links', 'categories_id' => Yii::$app->request->get('categories_id'), 'action' => 'ch', 'id' => $link->id]], ['label' => 'Ретактор контента', 'url' => ['/map/content', 'links_id' => $link->id]], ['label' => 'Добавить дочернюю ссылку', 'url' => ['/map/links', 'categories_id' => Yii::$app->request->get('categories_id'), 'parent' => $link->id, 'action' => 'add']]]], 'encodeLabel' => false, 'options' => ['class' => 'btn-default btn-xs']]), ['class' => 'col-sm-3 action text-right']) . Html::endTag('div'));
if ($link->child_exist == '1') {
$childs = \common\models\main\Links::find()->innerJoinWith('category')->where(['categories_id' => $this->categories_id])->andWhere(['categories.visible' => 1])->andWhere(['parent' => $link->id])->count();
if ($childs > 0) {
$html .= $this->getLinks($link->id);
}
}
}
$html .= Html::endTag('ul');
return $html;
}
示例8: renderExport
/**
* Renders the export menu
*
* @return string
*/
public function renderExport()
{
if ($this->export === false || !is_array($this->export) || empty($this->exportConfig) || !is_array($this->exportConfig)) {
return '';
}
$title = $this->export['label'];
$icon = $this->export['icon'];
$options = $this->export['options'];
$menuOptions = $this->export['menuOptions'];
$title = $icon == '' ? $title : "<i class='glyphicon glyphicon-{$icon}'></i> {$title}";
$action = $this->_module->downloadAction;
if (!is_array($action)) {
$action = [$action];
}
$encoding = ArrayHelper::getValue($this->export, 'encoding', 'utf-8');
$target = ArrayHelper::getValue($this->export, 'target', self::TARGET_POPUP);
$form = Html::beginForm($action, 'post', ['class' => 'kv-export-form', 'style' => 'display:none', 'target' => $target == self::TARGET_POPUP ? 'kvDownloadDialog' : $target]) . "\n" . Html::hiddenInput('export_filetype') . "\n" . Html::hiddenInput('export_filename') . "\n" . Html::hiddenInput('export_mime') . "\n" . Html::hiddenInput('export_config') . "\n" . Html::hiddenInput('export_encoding', $encoding) . "\n" . Html::textArea('export_content') . "\n</form>";
$items = empty($this->export['header']) ? [] : [$this->export['header']];
$iconPrefix = $this->export['fontAwesome'] ? 'fa fa-' : 'glyphicon glyphicon-';
foreach ($this->exportConfig as $format => $setting) {
$iconOptions = ArrayHelper::getValue($setting, 'iconOptions', []);
Html::addCssClass($iconOptions, $iconPrefix . $setting['icon']);
$label = empty($setting['icon']) || $setting['icon'] == '' ? $setting['label'] : Html::tag('i', '', $iconOptions) . ' ' . $setting['label'];
$items[] = ['label' => $label, 'url' => '#', 'linkOptions' => ['class' => 'export-' . $format, 'data-format' => ArrayHelper::getValue($setting, 'mime', 'text/plain')], 'options' => $setting['options']];
}
$itemsBefore = ArrayHelper::getValue($this->export, 'itemsBefore', []);
$itemsAfter = ArrayHelper::getValue($this->export, 'itemsAfter', []);
$items = ArrayHelper::merge($itemsBefore, $items, $itemsAfter);
return ButtonDropdown::widget(['label' => $title, 'dropdown' => ['items' => $items, 'encodeLabels' => false, 'options' => $menuOptions], 'options' => $options, 'containerOptions' => $this->exportContainer, 'encodeLabel' => false]) . $form;
}
示例9:
?>
<div class="form-group" data-activity="form-group">
<div class="col-sm-9">
<?php
echo net\frenzel\textareaautosize\yii2textareaautosize::widget(['model' => $model, 'attribute' => 'text']);
?>
<?php
echo Html::error($model, 'text', ['data-activity' => 'form-summary', 'class' => 'help-block hidden']);
?>
</div>
<div class="col-sm-3">
<label class="control-label" for="net_frenzel_activity_quick_action"> </label>
<?php
// a button group using Dropdown widget
echo ButtonDropdown::widget(['options' => ['id' => 'net_frenzel_activity_quick_action', 'class' => 'btn btn-info'], 'label' => 'Quick Actions', 'dropdown' => ['items' => [['label' => 'Not reached, call again', 'url' => '/'], ['label' => 'No time, pls. call back', 'url' => '#']]]]);
?>
</div>
</div>
<div id="container_activity_input" style="display:none">
<div class="col-md-12" data-activity="form-group">
<label class="control-label" for="activity-text"><?php
echo \Yii::t('net_frenzel_activity', 'Now');
?>
</label>
<?php
echo $form->field($model, 'type')->radioButtonGroup($model->TypeArray, ['id' => 'type-create', 'itemOptions' => ['labelOptions' => ['class' => 'btn btn-warning btn-sm']]])->label(false);
?>
<?php
echo Html::error($model, 'type', ['data-activity' => 'form-summary', 'class' => 'help-block hidden']);
示例10:
<div class="form-group">
<?php
echo Html::dropDownList('bulk-action', null, ArrayHelper::merge($searchModel->getPostStatus(), ['delete' => 'Delete']), ['class' => 'bulk-action form-control', 'prompt' => 'Bulk Action']);
?>
<?php
echo Html::button(Yii::t('writesdown', 'Apply'), ['class' => 'btn btn-flat btn-warning bulk-button']);
?>
<?php
echo Html::a(Yii::t('writesdown', 'Add New {postType}', ['postType' => $postType->post_type_sn]), ['create', 'post_type' => $postType->id], ['class' => 'btn btn-flat btn-primary']);
?>
<?php
echo ButtonDropdown::widget(['label' => Html::tag('i', '', ['class' => 'fa fa-user']) . ' Author', 'dropdown' => ['items' => [['label' => 'My Posts', 'url' => ['/post/index', 'post_type' => $postType->id, 'user' => Yii::$app->user->id]], ['label' => 'All Posts', 'url' => ['/post/index', 'post_type' => $postType->id]]]], 'split' => true, 'encodeLabel' => false, 'options' => ['class' => 'btn btn-flat btn-danger']]);
?>
<?php
echo Html::button(Html::tag('i', '', ['class' => 'fa fa-search']), ['class' => 'btn btn-flat btn-info', "data-toggle" => "collapse", "data-target" => "#post-search"]);
?>
</div>
</div>
<?php
Pjax::begin();
?>
<?php
echo $this->render('_search', ['model' => $searchModel, 'postType' => $postType, 'user' => $user]);
示例11:
* | | / // // ___//_ _// || __||_ _|
* | |/ // /(__ ) / / / /| || | | |
* |___//_//____/ /_/ /_/ |_||_| |_|
* @link http://vistart.name/
* @copyright Copyright (c) 2016 vistart
* @license http://vistart.name/license/
*/
use yii\bootstrap\Button;
use yii\bootstrap\ButtonDropdown;
use rho_my\modules\v1\controllers\PhoneController;
?>
<div class="panel-heading">
<strong><?php
echo Yii::t('my', 'Phone');
?>
</strong>
<div class="pull-right"><!--
<?php
echo ButtonDropdown::widget(['label' => 'Amount', 'dropdown' => ['items' => [['label' => 'All', 'url' => '#'], '<li role="separator" class="divider"></li>', ['label' => '10', 'url' => '#'], ['label' => '20', 'url' => '#'], ['label' => '50', 'url' => '#']]], 'options' => ['class' => 'btn-primary']]);
?>
<?php
echo ButtonDropdown::widget(['label' => 'Type', 'dropdown' => ['items' => [['label' => 'All', 'url' => '#'], '<li role="separator" class="divider"></li>', ['label' => 'Home', 'url' => '#']]], 'options' => ['class' => 'btn-primary']]);
?>
-->
<?php
echo Button::widget(['label' => '<span class="glyphicon glyphicon-plus"></span> ' . 'Add', 'encodeLabel' => false, 'options' => ['class' => 'btn-success', 'data-toggle' => 'modal', 'data-target' => '#modal-new']]);
?>
</div>
</div>
<?php
echo \rho_my\widgets\item\FormWidget::widget(['model' => $newModel, 'action' => PhoneController::getRouteNew()]);
示例12:
<?php
// echo $this->render('_search', ['model' =>$searchModel]);
?>
<div class="clearfix">
<p class="pull-left">
<?php
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']);
?>
</p>
<div class="pull-right">
<?php
echo \yii\bootstrap\ButtonDropdown::widget(['id' => 'giiant-relations', 'encodeLabel' => false, 'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . Yii::t('app', 'Relations'), 'dropdown' => ['options' => ['class' => 'dropdown-menu-right'], 'encodeLabels' => false, 'items' => [['label' => '<i class="glyphicon glyphicon-arrow-left"> Vidmage</i>', 'url' => ['vidmage/index']], ['label' => '<i class="glyphicon glyphicon-arrow-left"> Category</i>', 'url' => ['category/index']]]], 'options' => ['class' => 'btn-default']]);
?>
</div>
</div>
<?php
\yii\widgets\Pjax::begin(['id' => 'pjax-main', 'enableReplaceState' => false, 'linkSelector' => '#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']]);
?>
<div class="panel panel-default">
<div class="panel-heading">
<h2>
<i>Vidmage Categories</i>
</h2>
</div>
示例13: function
<?php
// echo $this->render('_search', ['model' =>$searchModel]);
?>
<div class="clearfix">
<p class="pull-left">
<?php
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']);
?>
</p>
<div class="pull-right">
<?php
echo \yii\bootstrap\ButtonDropdown::widget(['id' => 'giiant-relations', 'encodeLabel' => false, 'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . Yii::t('app', 'Relations'), 'dropdown' => ['options' => ['class' => 'dropdown-menu-right'], 'encodeLabels' => false, 'items' => [['label' => '<i class="glyphicon glyphicon-random"> Dept Emp</i>', 'url' => ['dept-emp/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Departments</i>', 'url' => ['departments/index']], ['label' => '<i class="glyphicon glyphicon-random"> Dept Manager</i>', 'url' => ['dept-manager/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Departments</i>', 'url' => ['departments/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Salaries</i>', 'url' => ['salaries/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Titles</i>', 'url' => ['titles/index']]]]]);
?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
Employees </div>
<div class="panel-body">
<div class="table-responsive">
<?php
echo GridView::widget(['layout' => '{summary}{pager}{items}{pager}', 'dataProvider' => $dataProvider, 'pager' => ['class' => yii\widgets\LinkPager::className(), 'firstPageLabel' => Yii::t('app', 'First'), 'lastPageLabel' => Yii::t('app', 'Last')], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'urlCreator' => function ($action, $model, $key, $index) {
// using the column name as key, not mapping to 'id' like the standard generator
示例14: getAsAddon
public function getAsAddon()
{
$ret_val = '';
$items = [];
$itemsLabels = [];
$form = $this->form;
$attribute = $this->attribute;
$this->model->{$attribute} = !$this->model->{$attribute} || !array_key_exists($this->model->{$attribute}, $this->priorities) ? 'normal' : $this->model->{$attribute};
foreach ($this->priorities as $name => $priority) {
$text = isset($priority['text']) ? $priority['text'] : ucfirst($name);
$priorityOptions = isset($this->_defaultPriorities[$name]) ? $this->_defaultPriorities[$name] : $this->defaultPriorities['normal'];
$options = isset($priority['options']) ? array_merge($priorityOptions, $priority['options']) : $priorityOptions;
switch ($this->addonType) {
case 'buttons':
case 'checkboxlist':
case 'radiolist':
$btnQualifier = 'btn';
break;
default:
$btnQualifier = 'bg';
break;
}
$options['class'] = "{$btnQualifier} {$btnQualifier}-" . $options['class'];
switch ($this->size) {
case 'tiny':
$options['class'] .= " {$btnQualifier}-xs";
break;
case 'small':
$options['class'] .= " {$btnQualifier}-sm";
break;
case 'large':
$options['class'] .= " {$btnQualifier}-lg";
break;
}
$options['value'] = $name;
$items[$name] = $text;
$itemsLabels[$name] = ['label' => $text, 'options' => $options, 'url' => '#'];
}
$itemsLabels[$this->model->{$attribute}]['options']['class'] .= ' active';
$this->options['inline'] = $this->inputsInline;
switch ($this->addonType) {
case 'dropdown':
$ret_val = \yii\bootstrap\ButtonDropdown::widget(['label' => 'Priority', 'dropdown' => ['items' => $itemsLabels], 'options' => ['class' => 'btn-primary']]);
break;
case 'radiolist':
$this->options['data-toggle'] = 'buttons';
$this->options['class'] = 'btn-group';
$this->options['item'] = function ($index, $label, $name, $checked, $value) use($itemsLabels) {
$itemOptions = ['value' => $value];
return Html::label(Html::radio($name, $checked, $itemOptions) . ' ' . $label['label'], null, $itemsLabels[$value]['options']);
};
$ret_val = $this->form->field($this->model, $this->attribute)->radioList($itemsLabels, $this->options)->label("Priority", ['class' => 'sr-only']);
break;
case 'checkboxlist':
$this->options['itemOptions'] = ['labelOptions' => ['class' => 'btn']];
$ret_val = $this->form->field($this->model, $this->attribute, ['options' => ['class' => 'btn-group', 'data-toggle' => 'buttons']])->checkBoxList($items, $this->options);
break;
default:
//Return as buttons by default
$model = $this->model;
$ret_val = implode(PHP_EOL, array_map(function ($item) use($model, $form, $attribute) {
//$item['options']['name'] = $model::formName()."[$attribute]";
$item['options']['id'] = strtolower($model::formName() . "-{$attribute}");
return Html::tag('button', $item['label'], $item['options']);
}, $itemsLabels));
break;
}
return $ret_val;
}
示例15: function
// echo $this->render('_search', ['model' =>$searchModel]);
?>
<div class="clearfix">
<p class="pull-left">
<?php
echo Html::a('<span class="glyphicon glyphicon-plus"></span> New', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<div class="pull-right">
<?php
echo \yii\bootstrap\ButtonDropdown::widget(['id' => 'giiant-relations', 'encodeLabel' => false, 'label' => '<span class="glyphicon glyphicon-paperclip"></span> Relations', 'dropdown' => ['options' => ['class' => 'dropdown-menu-right'], 'encodeLabels' => false, 'items' => [['label' => '<i class="glyphicon glyphicon-arrow-left"> Language</i>', 'url' => ['language/index']], ['label' => '<i class="glyphicon glyphicon-arrow-left"> Language</i>', 'url' => ['language/index']], ['label' => '<i class="glyphicon glyphicon-random"> Film Actor</i>', 'url' => ['film-actor/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Actor</i>', 'url' => ['actor/index']], ['label' => '<i class="glyphicon glyphicon-random"> Film Category</i>', 'url' => ['film-category/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Category</i>', 'url' => ['category/index']], ['label' => '<i class="glyphicon glyphicon-arrow-right"> Inventory</i>', 'url' => ['inventory/index']]]]]);
?>
</div>
</div>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['film_id', 'title', 'description:ntext', 'release_year', ["class" => yii\grid\DataColumn::className(), "attribute" => "language_id", "value" => function ($model) {
if ($rel = $model->getLanguage()->one()) {
return yii\helpers\Html::a($rel->name, ["language/view", "id" => $rel->language_id], ["data-pjax" => 0]);
} else {
return '';
}
}, "format" => "raw"], ["class" => yii\grid\DataColumn::className(), "attribute" => "original_language_id", "value" => function ($model) {
if ($rel = $model->getOriginalLanguage()->one()) {
return yii\helpers\Html::a($rel->name, ["language/view", "id" => $rel->language_id], ["data-pjax" => 0]);
} else {