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
b1b6a769
Commit
b1b6a769
authored
May 21, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'kartik-v-patch-4'
parents
1803d666
cb465bc2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
CHANGELOG.md
framework/CHANGELOG.md
+2
-1
UPGRADE.md
framework/UPGRADE.md
+4
-0
BaseHtml.php
framework/helpers/BaseHtml.php
+13
-5
No files found.
framework/CHANGELOG.md
View file @
b1b6a769
...
...
@@ -46,7 +46,8 @@ Yii Framework 2 Change Log
-
Enh #3252: Added support for case insensitive matching using ILIKE to PostgreSQL QueryBuilder (cebe)
-
Enh #3298: Supported configuring
`View::theme`
using a class name (netyum, qiangxue)
-
Enh #3328:
`BaseMailer`
generates better text body from html body (armab)
-
Enh #3518:
`yii\helpers\Html::encode()`
now replaces invalid code sequences with "�" (DaSourcerer)
-
Enh #3472: Added configurable option to encode spaces in dropDownLists and listBoxes (kartik-v)
-
Enh #3518:
`yii\helpers\Html::encode()`
now replaces invalid code sequences with "?" (DaSourcerer)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
framework/UPGRADE.md
View file @
b1b6a769
...
...
@@ -33,3 +33,7 @@ Upgrade from Yii 2.0 Beta
*
If you are sharing the same cache across different applications, you should configure
the
`keyPrefix`
property of the cache component to use some unique string.
Previously, this property was automatically assigned with a unique string.
*
If you are using
`dropDownList()`
,
`listBox()`
,
`activeDropDownList()`
, or
`activeListBox()`
of
`yii\helpers\Html`
, and your list options use multiple blank spaces to format and align
option label texts, you need to specify the option
`encodeSpaces`
to be true.
framework/helpers/BaseHtml.php
View file @
b1b6a769
...
...
@@ -729,6 +729,8 @@ class BaseHtml
*
* - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
* except that the array keys represent the optgroup labels specified in $items.
* - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
* Defaults to `false`.
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
...
...
@@ -743,7 +745,6 @@ class BaseHtml
}
$options
[
'name'
]
=
$name
;
$selectOptions
=
static
::
renderSelectOptions
(
$selection
,
$items
,
$options
);
return
static
::
tag
(
'select'
,
"
\n
"
.
$selectOptions
.
"
\n
"
,
$options
);
}
...
...
@@ -777,6 +778,8 @@ class BaseHtml
* - unselect: string, the value that will be submitted when no option is selected.
* When this attribute is set, a hidden field will be generated so that if no option is selected in multiple
* mode, we can still obtain the posted unselect value.
* - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
* Defaults to `false`.
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
...
...
@@ -804,7 +807,6 @@ class BaseHtml
$hidden
=
''
;
}
$selectOptions
=
static
::
renderSelectOptions
(
$selection
,
$items
,
$options
);
return
$hidden
.
static
::
tag
(
'select'
,
"
\n
"
.
$selectOptions
.
"
\n
"
,
$options
);
}
...
...
@@ -1354,6 +1356,8 @@ class BaseHtml
*
* - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options',
* except that the array keys represent the optgroup labels specified in $items.
* - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
* Defaults to `false`.
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
...
...
@@ -1407,6 +1411,8 @@ class BaseHtml
* - unselect: string, the value that will be submitted when no option is selected.
* When this attribute is set, a hidden field will be generated so that if no option is selected in multiple
* mode, we can still obtain the posted unselect value.
* - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character.
* Defaults to `false`.
*
* The rest of the options will be rendered as the attributes of the resulting tag. The values will
* be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
...
...
@@ -1540,15 +1546,17 @@ class BaseHtml
public
static
function
renderSelectOptions
(
$selection
,
$items
,
&
$tagOptions
=
[])
{
$lines
=
[];
$encodeSpaces
=
ArrayHelper
::
remove
(
$tagOptions
,
'encodeSpaces'
,
false
);
if
(
isset
(
$tagOptions
[
'prompt'
]))
{
$prompt
=
str_replace
(
' '
,
' '
,
static
::
encode
(
$tagOptions
[
'prompt'
])
);
$prompt
=
$encodeSpaces
?
str_replace
(
' '
,
' '
,
static
::
encode
(
$tagOptions
[
'prompt'
]))
:
static
::
encode
(
$tagOptions
[
'prompt'
]
);
$lines
[]
=
static
::
tag
(
'option'
,
$prompt
,
[
'value'
=>
''
]);
}
$options
=
isset
(
$tagOptions
[
'options'
])
?
$tagOptions
[
'options'
]
:
[];
$groups
=
isset
(
$tagOptions
[
'groups'
])
?
$tagOptions
[
'groups'
]
:
[];
unset
(
$tagOptions
[
'prompt'
],
$tagOptions
[
'options'
],
$tagOptions
[
'groups'
]);
$options
[
'encodeSpaces'
]
=
ArrayHelper
::
getValue
(
$options
,
'encodeSpaces'
,
$encodeSpaces
);
foreach
(
$items
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
$groupAttrs
=
isset
(
$groups
[
$key
])
?
$groups
[
$key
]
:
[];
...
...
@@ -1562,7 +1570,7 @@ class BaseHtml
$attrs
[
'selected'
]
=
$selection
!==
null
&&
(
!
is_array
(
$selection
)
&&
!
strcmp
(
$key
,
$selection
)
||
is_array
(
$selection
)
&&
in_array
(
$key
,
$selection
));
$lines
[]
=
static
::
tag
(
'option'
,
str_replace
(
' '
,
' '
,
static
::
encode
(
$value
)),
$attrs
);
$lines
[]
=
static
::
tag
(
'option'
,
(
$encodeSpaces
?
str_replace
(
' '
,
' '
,
static
::
encode
(
$value
))
:
static
::
encode
(
$value
)),
$attrs
);
}
}
...
...
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