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
63ddbe87
Commit
63ddbe87
authored
May 15, 2015
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `visible` option to `yii\bootstrap\Tab` widget items
parent
29ed43dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
CHANGELOG.md
CHANGELOG.md
+1
-0
Tabs.php
Tabs.php
+9
-1
TabsTest.php
tests/TabsTest.php
+30
-0
No files found.
CHANGELOG.md
View file @
63ddbe87
...
...
@@ -5,6 +5,7 @@ Yii Framework 2 bootstrap extension Change Log
-----------------------
-
Enh #38: Added object support for
`content`
option in
`Collapse`
class (pana1990, ItsReddi)
-
Enh #40: Added
`visible`
option to
`yii\bootstrap\Tab`
widget items (klimov-paul)
2.
0.4 May 10, 2015
------------------
...
...
Tabs.php
View file @
63ddbe87
...
...
@@ -70,7 +70,9 @@ class Tabs extends Widget
* - url: string, optional, an external URL. When this is specified, clicking on this tab will bring
* the browser to this URL. This option is available since version 2.0.4.
* - options: array, optional, the HTML attributes of the tab pane container.
* - active: boolean, optional, whether the item tab header and pane should be visible or not.
* - active: boolean, optional, whether this item tab header and pane should be active. If no item is marked as
* 'active' explicitly - the first one will be activated.
* - visible: boolean, optional, whether the item tab header and pane should be visible or not. Defaults to true.
* - items: array, optional, can be used instead of `content` to specify a dropdown items
* configuration array. Each item can hold three extra keys, besides the above ones:
* * active: boolean, optional, whether the item tab header and pane should be visible or not.
...
...
@@ -148,6 +150,9 @@ class Tabs extends Widget
}
foreach
(
$this
->
items
as
$n
=>
$item
)
{
if
(
!
ArrayHelper
::
remove
(
$item
,
'visible'
,
true
))
{
continue
;
}
if
(
!
array_key_exists
(
'label'
,
$item
))
{
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
}
...
...
@@ -228,6 +233,9 @@ class Tabs extends Widget
if
(
is_string
(
$item
))
{
continue
;
}
if
(
isset
(
$item
[
'visible'
])
&&
!
$item
[
'visible'
])
{
continue
;
}
if
(
!
array_key_exists
(
'content'
,
$item
))
{
throw
new
InvalidConfigException
(
"The 'content' option is required."
);
}
...
...
tests/TabsTest.php
View file @
63ddbe87
...
...
@@ -76,4 +76,34 @@ class TabsTest extends TestCase
$this
->
assertContains
(
$string
,
$out
);
}
}
public
function
testVisible
()
{
Tabs
::
$counter
=
0
;
$html
=
Tabs
::
widget
([
'items'
=>
[
[
'label'
=>
'Page1'
,
'content'
=>
'Page1'
,
],
[
'label'
=>
'InvisiblePage'
,
'content'
=>
'Invisible Page Content'
,
'visible'
=>
false
],
[
'label'
=>
'Dropdown1'
,
'items'
=>
[
[
'label'
=>
'Page2'
,
'content'
=>
'Page2'
],
[
'label'
=>
'InvisibleItem'
,
'content'
=>
'Invisible Item Content'
,
'visible'
=>
false
],
[
'label'
=>
'Page3'
,
'content'
=>
'Page3'
],
]
],
]
]);
$this
->
assertNotContains
(
'InvisiblePage'
,
$html
);
$this
->
assertNotContains
(
'Invisible Page Content'
,
$html
);
$this
->
assertNotContains
(
'InvisibleItem'
,
$html
);
$this
->
assertNotContains
(
'Invisible Item Content'
,
$html
);
}
}
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