Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
yii2bootstrap
Commits
8e26e127
Commit
8e26e127
authored
Apr 12, 2015
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2546: Added `visible` option to `yii\bootstrap\ButtonGroup::$buttons`
parent
6fc0a438
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
ButtonGroup.php
ButtonGroup.php
+8
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
ButtonGroupTest.php
tests/ButtonGroupTest.php
+29
-0
No files found.
ButtonGroup.php
View file @
8e26e127
...
...
@@ -7,6 +7,7 @@
namespace
yii\bootstrap
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Html
;
/**
...
...
@@ -20,6 +21,7 @@ use yii\helpers\Html;
* 'buttons' => [
* ['label' => 'A'],
* ['label' => 'B'],
* ['label' => 'C', 'visible' => false],
* ]
* ]);
*
...
...
@@ -44,6 +46,7 @@ class ButtonGroup extends Widget
*
* - label: string, required, the button label.
* - options: array, optional, the HTML attributes of the button.
* - visible: boolean, optional, whether this button is visible. Defaults to true.
*/
public
$buttons
=
[];
/**
...
...
@@ -80,6 +83,11 @@ class ButtonGroup extends Widget
$buttons
=
[];
foreach
(
$this
->
buttons
as
$button
)
{
if
(
is_array
(
$button
))
{
$visible
=
ArrayHelper
::
remove
(
$button
,
'visible'
,
true
);
if
(
$visible
===
false
)
{
continue
;
}
$button
[
'view'
]
=
$this
->
getView
();
if
(
!
isset
(
$button
[
'encodeLabel'
]))
{
$button
[
'encodeLabel'
]
=
$this
->
encodeLabels
;
...
...
CHANGELOG.md
View file @
8e26e127
...
...
@@ -6,6 +6,7 @@ Yii Framework 2 bootstrap extension Change Log
-
Bug #18:
`label`
option ignored by
`yii\bootstrap\Activefield::checkbox()`
and
`yii\bootstrap\Activefield::radio()`
(mikehaertl)
-
Bug #5984:
`yii\bootstrap\Activefield::checkbox()`
caused browser to link label to the wrong input (cebe)
-
Enh #2546: Added
`visible`
option to
`yii\bootstrap\ButtonGroup::$buttons`
(samdark, lukBarros)
-
Enh #7633: Added
`ActionColumn::$buttonOptions`
for defining HTML options to be added to the default buttons (cebe)
-
Enh: Added
`Nav::$dropDownCaret`
to allow customization of the dropdown caret symbol (cebe)
...
...
tests/ButtonGroupTest.php
0 → 100644
View file @
8e26e127
<?php
namespace
yiiunit\extensions\bootstrap
;
use
yii\bootstrap\Button
;
use
yii\bootstrap\ButtonGroup
;
/**
* @group bootstrap
*/
class
ButtonGroupTest
extends
TestCase
{
public
function
testContainerOptions
()
{
ButtonGroup
::
$counter
=
0
;
$out
=
ButtonGroup
::
widget
([
'buttons'
=>
[
[
'label'
=>
'button-A'
],
[
'label'
=>
'button-B'
,
'visible'
=>
true
],
[
'label'
=>
'button-C'
,
'visible'
=>
false
],
Button
::
widget
([
'label'
=>
'button-D'
]),
],
]);
static
::
assertContains
(
'button-A'
,
$out
);
static
::
assertContains
(
'button-B'
,
$out
);
static
::
assertContains
(
'button-B'
,
$out
);
static
::
assertNotContains
(
'button-C'
,
$out
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment