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
3048fdf6
Commit
3048fdf6
authored
May 26, 2014
by
armab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve array support for "data" attribute in renderTagAttributes()
parent
66477091
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
BaseHtml.php
framework/helpers/BaseHtml.php
+7
-1
No files found.
framework/helpers/BaseHtml.php
View file @
3048fdf6
...
...
@@ -1569,6 +1569,8 @@ class BaseHtml
* the array will be "expanded" and a list data attributes will be rendered. For example,
* if `'data' => ['id' => 1, 'name' => 'yii']`, then this will be rendered:
* `data-id="1" data-name="yii"`.
* Additionally `'data' => ['params' => ['id' => 1, 'name' => 'yii'], 'status' => 'ok']` will be rendered as:
* `data-params='{"id":1,"name":"yii"}' data-status="ok"`.
*
* @param array $attributes attributes to be rendered. The attribute values will be HTML-encoded using [[encode()]].
* @return string the rendering result. If the attributes are not empty, they will be rendered
...
...
@@ -1595,7 +1597,11 @@ class BaseHtml
}
}
elseif
(
is_array
(
$value
)
&&
$name
===
'data'
)
{
foreach
(
$value
as
$n
=>
$v
)
{
$html
.=
"
$name
-
$n
=
\"
"
.
static
::
encode
(
$v
)
.
'"'
;
if
(
is_array
(
$v
))
{
$html
.=
"
$name
-
$n
='"
.
Json
::
encode
(
$v
)
.
"'"
;
}
else
{
$html
.=
"
$name
-
$n
=
\"
"
.
static
::
encode
(
$v
)
.
'"'
;
}
}
}
elseif
(
$value
!==
null
)
{
$html
.=
"
$name
=
\"
"
.
static
::
encode
(
$value
)
.
'"'
;
...
...
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