yiisoft / yii2-bootstrap Goto Github PK
View Code? Open in Web Editor NEWYii 2 Bootstrap 3 Extension
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
Yii 2 Bootstrap 3 Extension
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
I tried to update using "composer update" command in the "advance" project folder but i did not get the latest files such as those included in the zip downloads.
The composer.json file already has this line included for bootstrap, "yiisoft/yii2-bootstrap": "~2.0.0"
.
This code works if I use yii\widgets\ActiveForm
instead of yii\bootstrap\ActiveForm
<?= $form->field($model, 'type')->radioList(Customer::getTypes(), [
'itemOptions' => [
'data-attribute' => 'test'
]
]) ?>
This issue has originally been reported by @spikyjt at yiisoft/yii2#7480.
Moved here by @cebe.
The Bootstrap dropdown widget allows rendering multi-level navs, but hides them by default because the dropdown-menu
class is added to sub menus, inherited from the parent options
property. Although the docs mention adding your own styling to display them as you wish, they should not have this class, as it is inappropriate in this situation.
Either the dropdown widget should only allow one level of menu (not preferred in my opinion) or options should be available for sub menus.
We could either have a submenuOptions
property that affects all sub menus, and/or a submenuOptions
property in each items
array to specify them individually for each sub menu. I can see pros and cons to both, but the second way is what the old class CMenu
did, so it might be more consistent.
The font-awesome prefixes are fa fa-
, similar to glyphicon's glyphicon glyphicon-
. Can the Html::icon
function be updated to use a custom prefix by default?
This issue has originally been reported by @kullar84 at yiisoft/yii2#5629.
Moved here by @cebe.
Please add options to subitems so we could add class to sub ul tag.
if ($items !== null) {
$linkOptions['data-toggle'] = 'dropdown';
Html::addCssClass($options, 'dropdown');
Html::addCssClass($linkOptions, 'dropdown-toggle');
$label .= ' ' . Html::tag('b', '', ['class' => 'caret']);
if (is_array($items)) {
if ($this->activateItems) {
$items = $this->isChildActive($items, $active);
}
$items = Dropdown::widget([
'items' => $items,
'encodeLabels' => $this->encodeLabels,
'clientOptions' => false,
'options' => $options,
'view' => $this->getView(),
]);
}
}
In yii\bootstrap\Modal the tabindex="-1" option prevents Select2 search input from working.
This issue has originally been reported by @klevron at yiisoft/yii2#10103.
Moved here by @cebe.
Actually if I want to display a label in an inline form, I have to do this :
<?php $form = ActiveForm::begin(['layout' => 'inline']); ?>
<?= $form->field($model, 'field')->label(null, ['class' => '']) ?>
<?php ActiveForm::end(); ?>
https://github.com/yiisoft/yii2-bootstrap/blob/2.0.5/ActiveField.php#L379
There should be a proper way to do this (same for enableError
), no ?
Extracted from yiisoft/yii2#5697
Extracted from yiisoft/yii2#7427
A submenu options array adds flexibility to the dropdown, allowing custom attributes to be added to submenus.
The submenu should not have the class dropdown-menu
. Having this class is incorrect as far as Bootstrap is concerned.
https://github.com/yiisoft/yii2-bootstrap/blob/master/Tabs.php#L193
The problem is this line which always uses the 'div'
tag even when the documentation says that I can use any tag I want on an item using the itemOptions['tag']
key
This issue has originally been reported by @RomeroMsk at yiisoft/yii2#4890.
Moved here by @cebe.
Just a feature request: config option to "remember" active tab in Tabs widget (to activate last opened tab after reloading the page).
It is not so hard to implement with application JS, but can be a feature of widget. We need to register just two event handlers:
location.hash
on tab click:$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
location.hash = e.target.hash;
});
We need this because of https://github.com/twbs/bootstrap/blob/master/js/tab.js#L126
2. On document ready activate the tab:
$(document).ready(function() {
if (location.hash.length) {
$('[data-toggle="tab"], [data-toggle="pill"]').filter('[href="' + location.hash + '"]').tab('show');
}
}
This issue has originally been reported by @invaderhd at yiisoft/yii2#7499.
Moved here by @cebe.
In a project I use Navbar extensively and I found that it should be more generic, for example:
The Navbar is a great class and works like a charm in the default bootstrap theme, but in custom layouts it is not generic enough to do it job.
Keep the good working guys ;)
The BootstrapAsset dependency is already defined in app\assets\AppAsset where it can be overriden with a customized Bootstrap stylesheet.
Adding dependency in BootstrapPluginAsset is not only redundant, it prevents us from overriding the default Bootstrap in AppAsset.
Migrated from yiisoft/yii2#5207
This issue has originally been reported by @Okeanos at yiisoft/yii2#8380.
Moved here by @cebe.
Since 2.0.4 (#7284) the Bootstrap Tab widget supports external links for top level items. It would nice (and feature complete) if this functionality could be extended to the dropdown menus as well.
Preferably including support for all link options, e.g. making it a POST
action.
Either way it should be changed to ">=2.0.5" before next release.
Hy!
When i use .alert-dismissible class in the widget options, close button is diplayed.
I think this is a little bug.
http://getbootstrap.com/javascript/#alerts
http://getbootstrap.com/components/#alerts
We can have a widget to bootstrap label?
THE place to write this, for example:
´´
http://getbootstrap.com/components/#labels
´´
Could Write this:
echo Label::widget( [ 'Order Open', 'default' ] );
echo Label::widget( [ 'BlackFriday Day', 'primary' ] );
echo Label::widget( [ 'Vip Client', 'success' ] );
or
echo Label::widget([
[ 'Order Open', 'default' ],
[ 'BlackFriday Day', 'primary' ],
[ 'Vip Client', 'success' ]
]);
AS advantages I see:
1 - encapsulate another native bootstrap component as widget, avoiding use native code html / css / js expalhados the views.
2 - Item 1 provides the safety switch to bootstrap 4, 5 ... 10 for example, over the years, ensuring that almost no or little html the views, even q markup change of a label, as in this incapsulada component widget bootstrap package, we can develop and build perfect miegação processes.
3 - It is elegant views with little or no text html and css and js own, some thought could be a target almost did not write html, css and js in views, using the maximum YII2.x widgets API
4 - Even with something as trivial, encpsular alone is already an advantage is for compatibility, migration, and code views of beauty or simply by providing a more complete API.
yii\bootstrap\Navbar R120
if ($this->brandLabel !== false) {
Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
echo Html::a($this->brandLabel, $this->brandUrl === false ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions);
}
Is it possible to add an option to just print the brandLabel?
Now I can render a view with custom html
NavBar::begin([
'options' => [
'class' => 'navbar navbar-default',
'id' => 'nav-first',
],
'brandLabel' => Yii::$app->view->render('_brandLabel'),
]);
Code in view
<?= \yii\bootstrap\Nav::widget([
'items' => $this->context->menu
]); ?>
menu:
[
0 => [
'label' => 'Test'
'url' => '/portalpage/page/default?user_id=13&id=1'
'items' => []
'options' => [
'class' => 'menu-item'
'target' => '_self'
]
]
1 => [
'label' => 'За на�'
'url' => '/portalpage/page/default?user_id=13&id=2'
'items' => []
'options' => [
'class' => 'menu-item'
'target' => '_self'
]
]
]
HTML
<ul id="w2" class="nav">
<li class="menu-item dropdown open" target="_self"><a class="dropdown-toggle" href="/portalpage/page/default?user_id=13&id=1" data-toggle="dropdown" aria-expanded="true">Test <b class="caret"></b></a>
<ul id="w3" class="dropdown-menu"></ul></li>
<li class="menu-item dropdown" target="_self"><a class="dropdown-toggle" href="/portalpage/page/default?user_id=13&id=2" data-toggle="dropdown">За нас <b class="caret"></b></a><ul id="w4" class="dropdown-menu"></ul></li>
</ul>
As you can see there are redundant dropdowns for empty subitems array
I think that in yii\bootstrap\Nav at line 185 the code should be
if (is_array($items) && !empty($items)) {
...
}
instead of
if (is_array($items)) {
....
}
It reported in yiisoft/yii2#6495
I focus on the Nav
widget for being the more used, other widgets that can benefit from this are Carousel
, Tabs
, etc.
Currently Nav::$items
is an array of items, I propose to have Nav::$itemConfig
which will contain a default configuration for each item or several properties like Nav::$itemOptions
, Nav::$linkOptions
, Nav::$labelOptions
etc.
For example:
echo Collapse::widget([
'items' => [
'Introduction' => 'This is the first collapsable menu',
'Second panel' => [
'content' => 'This is the second collapsable menu',
],
]
])
would be the equivalent of
echo Collapse::widget([
'items' => [
[
'label' => 'Introduction',
'content' => 'This is the first collapsable menu',
],
[
'lable' => 'Second panel',
'content' => 'This is the second collapsable menu',
],
]
])
The patch is actually very simple, for example for the Tabs widget you only need to change the lines https://github.com/yiisoft/yii2-bootstrap/blob/master/Tabs.php#L155-159 to
if (!is_string($key) && !array_key_exists('label', $item)) {
throw new InvalidConfigException(
"The 'label' option is required."
);
}
if (is_string($item)) {
$item = ['content' => $item];
}
$label = is_string($key) ? $key : $item['label'];
$encodeLabel = isset($item['encode'])
? $item['encode']
: $this->encodeLabels;
$label = $encodeLabel
? Html::encode($label)
: $label;
This issue has originally been reported by @nterms at yiisoft/yii2#6614.
Moved here by @cebe.
According to the Bootstrap docs here the parent
option is used to determine whether to hide others when some panel is opened. However, setting this with clientOptions
would not give the expected behavior, because of the line 133 on widget.
'data-parent' => '#' . $this->options['id']
This is important specially if you want to stop panels collapsing when you expand others. Simply when you want to keep two or more panels opened.
This issue has originally been reported by @n099y at yiisoft/yii2#9511.
Moved here by @cebe.
The way the options in the navbar is currently setup is very confusing. I have been working on modifying these containers just now and those options did my head in for a moment.
'containerOptions' => [ ],
'innerContainerOptions' => [ ],
'renderInnerContainer' => true,
As you can see in the image below the innerContainer is outside of container. I propose the containerOptions be changed to something like itemContainerOptions or something that separates it from that outer container that is actually innerContainer.
The class documentation is obviously created from the latest development branch of this extension. This leads to some confusion. For example I've read about the visible
feature for yii\bootstrap\Tabs
here:
http://www.yiiframework.com/doc-2.0/yii-bootstrap-tabs.html#$items-detail
So:
visible
feature should get a note like "since 2.0.5" or similar.On a sidenote I wonder, when the next release of this extension is planned.
since bower-asset/bootstrap v3.3.5, I have those weird warnings
Failed to decode downloaded font: /assets/edae1c82/fonts/glyphicons-halflings-regular.woff2
Failed to decode downloaded font: /assets/edae1c82/fonts/glyphicons-halflings-regular.woff
Failed to decode downloaded font: /assets/edae1c82/fonts/glyphicons-halflings-regular.ttf
turn out it involves some political issue which affects lot of people out there
twbs/bootstrap#16708
twbs/bootstrap#16359
twbs/bootstrap#16663
I really dont know how to make yii2-bootstrap use bower-asset/bootstrap v3.3.4, or even better, use the original bootstrap package twbs/bootstrap
Hi.
Skip CI in ptBR docs like outhers languages set? What?
This issue has originally been reported by @machour at yiisoft/yii2#7189.
Moved here by @cebe.
Scenario : I'm in a form (A), and I use yii\bootstrap\Modal to open a new form (B) used to add a new option in my dropDownList() located in A. (see attached screenshot for better understanding)
I want the modal toggle button to be displayed near the dropDownList(), so I go ahead and do :
echo $form->field($model, 'project_id')->dropDownList(ArrayHelper::map(Project::find()->all(), 'id', 'label'), ['prompt' => Yii::t('app', 'Select a project')]);
Modal::begin([
'header' => '<b>' . Yii::t('app', 'Create new project') . '</b>',
'toggleButton' => ['label' => '+', 'href' => Url::to(['/Bcontroller/ajaxCreate'])],
]);
Modal::end();
Problem : when generated, the B form will be nested in the A form, which brakes things.
Possible solution : a possible solution would be to render the toggleButton right away, as it is done now, but delay all the modal markup & content to View::EVENT_END_BODY, to make sure that if the modal contains a form, it won't be nested in an other one.
I'd cook a patch but I'm not sure how the modal content should be captured with Yii development guidelines. Please advise if a patch like this would be acceptable.
This issue has originally been reported by @qq510846 at yiisoft/yii2#3678.
Moved here by @cebe.
Nav is a great Widget!
i want to improve function isItemActive(),
then can support "range page" property, you can use:
Nav::widget([
'items' => ['label' => 'Product', 'url' => ['product/index'], 'rangepage' => [['product/view']]],
])
and the improved function isItemActive():
protected function isItemActive($item)
{
if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) {
$route = $item['url'][0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
if (!isset($item['rangepage'])) {
if (ltrim($route, '/') !== $this->route) {
return false;
}
unset($item['url']['#']);
if (count($item['url']) > 1) {
foreach (array_splice($item['url'], 1) as $name => $value) {
if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) {
return false;
}
}
}
} else {
if (ltrim($route, '/') == $this->route) {
unset($item['url']['#']);
if (count($item['url']) > 1) {
$_m = true;
foreach (array_splice($item['url'], 1) as $name => $value) {
if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) {
$_m = false;
break;
}
}
if ($_m) {
return true;
}
} else {
return true;
}
}
foreach ($item['rangepage'] as $rpitem) {
$rproute = $rpitem[0];
if ($rproute[0] !== '/' && Yii::$app->controller) {
$rproute = Yii::$app->controller->module->getUniqueId() . '/' . $rproute;
}
if (ltrim($rproute, '/') !== $this->route) {
continue;
}
$range_matched = true;
foreach (array_splice($rpitem, 1) as $name => $value) {
if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) {
$range_matched = false;
break;
}
}
if ($range_matched) {
return true;
}
}
return false;
}
return true;
}
return false;
}
代码如下:
$menuLeftItems = [
[
'label' => '控制台',
//注意,这儿没有url这个键名
'items' => [
[
'label' => '概要', 'url' => ['/site/index']
],
[
'label' => '个人设置', 'url' => ['/site/profile']
],
[
'label' => '插件', 'url' => ['/plugin']
],
[
'label' => '外观', 'url' => ['/theme']
],
]
],
];
echo Nav::widget([
'options' => [
'activateParents' => true,
'class' => 'navbar-nav navbar-left'
],
'items' => $menuLeftItems,
]);
当父级没有url
这个键名,设置了activateParents
也没有用,需要加一个url=>[]
,但是url
只能指定众多子节点的其中一个,所以选中其它子节点父级也没法高亮
Migrated from yiisoft/yii2#7519
Add support of these button groups to bootstrap/ActiveField.
Migrated from yiisoft/yii2#1344
In case of so deep integration with Bootstrap 3 maybe it has sense to add support of form static controls because they are very close by markup to the regular form fields except the paragraph is used instead of the input? It should be useful when some attribute should be rendered as non-editable value.
This issue has originally been reported by @ASlatius at yiisoft/yii2#6720.
Moved here by @cebe.
When rendering with 'split'=>true, the dropdown-toggle is rendered with a second button. This button gets the same options as the primary buttons.
This is getting problematic when you try and set options for JavaScript usage like 'id' and 'onclick'.
see #15
This issue has originally been reported by @djfly at yiisoft/yii2#8567.
Moved here by @cebe.
it's not have label at left
if set enclosedByLabel false checkbox is not have name and Not aligned
With the NavBar Widget in the NavBar::begin if you give it a class => ['navbar-inverse navbar-fixed-top']
the toggle button works on smaller screen for each label. But if you remove the class in the NavBar::begin the toggle button still appears but when you press it no action occurs when inspecting the element in google chrome you can see it is a button but you can't click on it to view your nav buttons.
Migrated from yiisoft/yii2#7709
yii\bootstrap\ButtonDropdown::renderButton()
if $this->split is true,
splitButton and button id is same
As title says, it is not possible to eliminate a dropdown item from being active. You have to specify an absolute url. Documentation is not clear on the active
attribute in this scenario, and it IS possible to set active
to true
.
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'activateParents' => true,
'items' => [
[
'label' => 'Demo User',
'url' => false,
'visible' => !Yii::$app->user->isGuest,
'items' => [
[
'label' => 'My account',
'url' => ['account/overview'],
'active' => $controllerId == 'account', // This works
],
[
'label' => 'Send feedback',
'url' => ['help/support/index'],
'active' => false, // This doesn't
],
[
'label' => 'Logout',
'url' => ['login/logout']
],
],
],
],
]);
Can you provide simple way to insert a bootstrap glyphicon?
Putting long string "" in label is very unprofessional.
Take a look at these code:
<?= Html::a('<span class="glyphicon glyphicon-print"></span> ' . Yii::t('app', 'Print'), ['print'], ['class' => 'btn']); ?>
<?= ButtonDropdown::widget([
'label' => '<span class="glyphicon glyphicon-print"></span> ' . Yii::t('app', 'Print'),
'encodeLabel' => false,
'dropdown' => [
'items' => [
['label' => Yii::t('app', 'User')],
['label' => '<span class="glyphicon glyphicon-envelope"></span> ' . Yii::t('app', 'Emails'), 'url' => ['print-emails']],
['label' => '<span class="glyphicon glyphicon-home"></span> ' . Yii::t('app', 'Addresses'), 'url' => ['print-addresses']],
['label' => '<span class="glyphicon glyphicon-earphone"></span> ' . Yii::t('app', 'Telephones'), 'url' => ['print-telephones']],
],
],
'options' => [
'class' => 'btn btn-info',
],
]); ?>
It reported in yiisoft/yii2#8357
This issue has originally been reported by @mrdan32 at yiisoft/yii2#3679.
Moved here by @cebe.
How do we disbale dropdown menu by this code:
if ($items !== null) {
$linkOptions['data-toggle'] = 'dropdown';
Html::addCssClass($options, 'dropdown');
Html::addCssClass($linkOptions, 'dropdown-toggle');
$label .= ' ' . Html::tag('b', '', ['class' => 'caret']);
if (is_array($items)) {
if ($this->activateItems) {
$items = $this->isChildActive($items, $active);
}
$items = Dropdown::widget([
'items' => $items,
'encodeLabels' => $this->encodeLabels,
'clientOptions' => false,
'view' => $this->getView(),
]);
}
}
And set the class for ul tag?
This issue has originally been reported by @Tigrov at yiisoft/yii2#6527.
Moved here by @cebe.
$options['itemOptions']
is not used for generation inputs.
https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L254
https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L280
#5483
I accidentally updated to Bootstrap 3.5 - due to using sass bootstrap - and noticed they did fix a series of bugs.
Do you intend to add '3.5' '3.3.5' to composer.json ?
I admit that I'm new to yii2 testing. So if I'm missing some documentation, please let me know.
I tried to get startet with unit testing for yii2-bootstrap. So I just cloned the forked repository and tried to install the required composer packages:
$ git clone [email protected]:mikehaertl/yii2-bootstrap.git
$ cd yii2-bootstrap
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package bower-asset/bootstrap could not be found in any version, there may be a typo in the package name.
Problem 2
- Installation request for yiisoft/yii2-bootstrap 2.0.x-dev -> satisfiable by yiisoft/yii2-bootstrap[2.0.x-dev].
- yiisoft/yii2-bootstrap 2.0.x-dev requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found.
Problem 3
- yiisoft/yii2 2.0.3 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.2 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.1 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- Installation request for yiisoft/yii2 * -> satisfiable by yiisoft/yii2[2.0.0, 2.0.1, 2.0.2, 2.0.3].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Am I doing something wrong?
Hi i write an GlyphIcon Helper maybe you want to include it it would be nice
This issue has originally been reported by @alagodich at yiisoft/yii2#8028.
Moved here by @cebe.
Hello
As stated here: http://getbootstrap.com/javascript/#dropdowns-events
All dropdown events are fired at the .dropdown-menu's parent element.
But parent container for widget is being rendered via Html::beginTag
and we cannot assign any events to it with 'clientEvents' option.
return implode("\n", [
Html::beginTag($tag, $this->containerOptions),
Autohide alerts widget, new propert autohide
I think the alerts are ideas to display flash messages, and other uses.
Could have a autohide property of the type that receives a whole number in seconds. By default could do a jquery fade or on the property autohide be of type array, which receives: Time in seconds and effect (hide, slide, fade ...)
Let me know the opnion of the community please!
Hugs You!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.