Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
b672b818
Commit
b672b818
authored
Sep 29, 2014
by
Nikola Kovacs
Committed by
Alexander Makarov
Sep 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bootstrap Collapse items property uses label element and encodes by default, like Tabs
Fixes #5232 and #5231
parent
88dabc49
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
14 deletions
+31
-14
CHANGELOG.md
extensions/bootstrap/CHANGELOG.md
+2
-1
Collapse.php
extensions/bootstrap/Collapse.php
+26
-13
UPGRADE.md
framework/UPGRADE.md
+3
-0
No files found.
extensions/bootstrap/CHANGELOG.md
View file @
b672b818
...
@@ -4,7 +4,8 @@ Yii Framework 2 bootstrap extension Change Log
...
@@ -4,7 +4,8 @@ Yii Framework 2 bootstrap extension Change Log
2.
0.0 under development
2.
0.0 under development
-----------------------
-----------------------
-
no changes in this release.
-
Chg #5231: Collapse
`items`
property uses
`label`
element instead of array key for headers (nkovacs)
-
Chg #5232: Collapse encodes headers by default (nkovacs)
2.0.0-rc September 27, 2014
2.0.0-rc September 27, 2014
...
...
extensions/bootstrap/Collapse.php
View file @
b672b818
...
@@ -20,13 +20,15 @@ use yii\helpers\Html;
...
@@ -20,13 +20,15 @@ use yii\helpers\Html;
* echo Collapse::widget([
* echo Collapse::widget([
* 'items' => [
* 'items' => [
* // equivalent to the above
* // equivalent to the above
* 'Collapsible Group Item #1' => [
* [
* 'label' => 'Collapsible Group Item #1',
* 'content' => 'Anim pariatur cliche...',
* 'content' => 'Anim pariatur cliche...',
* // open its content by default
* // open its content by default
* 'contentOptions' => ['class' => 'in']
* 'contentOptions' => ['class' => 'in']
* ],
* ],
* // another group item
* // another group item
* 'Collapsible Group Item #2' => [
* [
* 'label' => 'Collapsible Group Item #1',
* 'content' => 'Anim pariatur cliche...',
* 'content' => 'Anim pariatur cliche...',
* 'contentOptions' => [...],
* 'contentOptions' => [...],
* 'options' => [...],
* 'options' => [...],
...
@@ -45,20 +47,22 @@ class Collapse extends Widget
...
@@ -45,20 +47,22 @@ class Collapse extends Widget
* @var array list of groups in the collapse widget. Each array element represents a single
* @var array list of groups in the collapse widget. Each array element represents a single
* group with the following structure:
* group with the following structure:
*
*
* ```php
* - label: string, required, the group header label.
* // item key is the actual group header
* - encode: boolean, optional, whether this label should be HTML-encoded. This param will override
* 'Collapsible Group Item #1' => [
* global `$this->encodeLabels` param.
* // required, the content (HTML) of the group
* - content: string, required, the content (HTML) of the group
* 'content' => 'Anim pariatur cliche...',
* - options: array, optional, the HTML attributes of the group
* // optional the HTML attributes of the content group
* - contentOptions: optional, the HTML attributes of the group's content
* 'contentOptions' => [],
*
* // optional the HTML attributes of the group
* 'options' => [],
* ]
* ```
* ```
*/
*/
public
$items
=
[];
public
$items
=
[];
/**
* @var boolean whether the labels for header items should be HTML-encoded.
*/
public
$encodeLabels
=
true
;
/**
/**
* Initializes the widget.
* Initializes the widget.
...
@@ -88,7 +92,11 @@ class Collapse extends Widget
...
@@ -88,7 +92,11 @@ class Collapse extends Widget
{
{
$items
=
[];
$items
=
[];
$index
=
0
;
$index
=
0
;
foreach
(
$this
->
items
as
$header
=>
$item
)
{
foreach
(
$this
->
items
as
$item
)
{
if
(
!
isset
(
$item
[
'label'
]))
{
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
}
$header
=
$item
[
'label'
];
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
[]);
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
[]);
Html
::
addCssClass
(
$options
,
'panel panel-default'
);
Html
::
addCssClass
(
$options
,
'panel panel-default'
);
$items
[]
=
Html
::
tag
(
'div'
,
$this
->
renderItem
(
$header
,
$item
,
++
$index
),
$options
);
$items
[]
=
Html
::
tag
(
'div'
,
$this
->
renderItem
(
$header
,
$item
,
++
$index
),
$options
);
...
@@ -113,6 +121,11 @@ class Collapse extends Widget
...
@@ -113,6 +121,11 @@ class Collapse extends Widget
$options
[
'id'
]
=
$id
;
$options
[
'id'
]
=
$id
;
Html
::
addCssClass
(
$options
,
'panel-collapse collapse'
);
Html
::
addCssClass
(
$options
,
'panel-collapse collapse'
);
$encodeLabel
=
isset
(
$item
[
'encode'
])
?
$item
[
'encode'
]
:
$this
->
encodeLabels
;
if
(
$encodeLabel
)
{
$header
=
Html
::
encode
(
$header
);
}
$headerToggle
=
Html
::
a
(
$header
,
'#'
.
$id
,
[
$headerToggle
=
Html
::
a
(
$header
,
'#'
.
$id
,
[
'class'
=>
'collapse-toggle'
,
'class'
=>
'collapse-toggle'
,
'data-toggle'
=>
'collapse'
,
'data-toggle'
=>
'collapse'
,
...
...
framework/UPGRADE.md
View file @
b672b818
...
@@ -19,6 +19,9 @@ Upgrade from Yii 2.0 RC
...
@@ -19,6 +19,9 @@ Upgrade from Yii 2.0 RC
was possible. If your timestamps are stored in the database without a timezone identifier you have to ensure they are in UTC or
was possible. If your timestamps are stored in the database without a timezone identifier you have to ensure they are in UTC or
add a timezone identifier explicitly.
add a timezone identifier explicitly.
*
`yii\bootstrap\Collapse`
is now encoding labels by default.
`encode`
item option and global
`encodeLabels`
property were
introduced to disable it. Keys are no longer used as labels. You need to remove keys and use
`label`
item option instead.
Upgrade from Yii 2.0 Beta
Upgrade from Yii 2.0 Beta
-------------------------
-------------------------
...
...
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