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
093cb97f
Commit
093cb97f
authored
Jul 22, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4393 from kartik-v/patch-1
Better fix for Dropdown container options
parents
6dc056b3
2eb9cf80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
Dropdown.php
extensions/bootstrap/Dropdown.php
+12
-7
No files found.
extensions/bootstrap/Dropdown.php
View file @
093cb97f
...
@@ -40,7 +40,12 @@ class Dropdown extends Widget
...
@@ -40,7 +40,12 @@ class Dropdown extends Widget
*/
*/
public
$encodeLabels
=
true
;
public
$encodeLabels
=
true
;
/**
* @var array the HTML attributes for the widget container tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
protected
$_containerOptions
=
[];
/**
/**
* Initializes the widget.
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
* If you override this method, make sure you call the parent implementation first.
...
@@ -49,6 +54,7 @@ class Dropdown extends Widget
...
@@ -49,6 +54,7 @@ class Dropdown extends Widget
{
{
parent
::
init
();
parent
::
init
();
Html
::
addCssClass
(
$this
->
options
,
'dropdown-menu'
);
Html
::
addCssClass
(
$this
->
options
,
'dropdown-menu'
);
$this
->
_containerOptions
=
$this
->
options
;
}
}
/**
/**
...
@@ -56,17 +62,16 @@ class Dropdown extends Widget
...
@@ -56,17 +62,16 @@ class Dropdown extends Widget
*/
*/
public
function
run
()
public
function
run
()
{
{
echo
$this
->
renderItems
(
$this
->
items
,
$this
->
options
);
echo
$this
->
renderItems
(
$this
->
items
);
}
}
/**
/**
* Renders menu items.
* Renders menu items.
* @param array $items the menu items to be rendered
* @param array $items the menu items to be rendered
* @param array $containerOptions the HTML attributes for the widget container tag
* @return string the rendering result.
* @return string the rendering result.
* @throws InvalidConfigException if the label option is not specified in one of the items.
* @throws InvalidConfigException if the label option is not specified in one of the items.
*/
*/
protected
function
renderItems
(
$items
,
$containerOptions
)
protected
function
renderItems
(
$items
)
{
{
$lines
=
[];
$lines
=
[];
foreach
(
$items
as
$i
=>
$item
)
{
foreach
(
$items
as
$i
=>
$item
)
{
...
@@ -88,13 +93,13 @@ class Dropdown extends Widget
...
@@ -88,13 +93,13 @@ class Dropdown extends Widget
$linkOptions
[
'tabindex'
]
=
'-1'
;
$linkOptions
[
'tabindex'
]
=
'-1'
;
$content
=
Html
::
a
(
$label
,
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
),
$linkOptions
);
$content
=
Html
::
a
(
$label
,
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
),
$linkOptions
);
if
(
!
empty
(
$item
[
'items'
]))
{
if
(
!
empty
(
$item
[
'items'
]))
{
unset
(
$containerOptions
[
'id'
]);
unset
(
$
this
->
_
containerOptions
[
'id'
]);
$this
->
renderItems
(
$item
[
'items'
]
,
$containerOptions
);
$this
->
renderItems
(
$item
[
'items'
]);
Html
::
addCssClass
(
$options
,
'dropdown-submenu'
);
Html
::
addCssClass
(
$options
,
'dropdown-submenu'
);
}
}
$lines
[]
=
Html
::
tag
(
'li'
,
$content
,
$options
);
$lines
[]
=
Html
::
tag
(
'li'
,
$content
,
$options
);
}
}
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$lines
),
$this
->
o
ptions
);
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$lines
),
$this
->
_containerO
ptions
);
}
}
}
}
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