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
53b4ed3d
Commit
53b4ed3d
authored
Aug 26, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved label for Sort::link() to html options
parent
39c002e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
Sort.php
framework/yii/data/Sort.php
+10
-5
DataColumn.php
framework/yii/grid/DataColumn.php
+1
-1
No files found.
framework/yii/data/Sort.php
View file @
53b4ed3d
...
...
@@ -125,6 +125,7 @@ class Sort extends Object
* if it is not currently sorted (the default value is ascending order).
* - The "label" element specifies what label should be used when calling [[link()]] to create
* a sort link. If not set, [[Inflector::camel2words()]] will be called to get a label.
* Note that it will not be HTML-encoded.
*
* Note that if the Sort object is already created, you can only use the full format
* to configure every attribute. Each attribute must include these elements: asc and desc.
...
...
@@ -285,14 +286,15 @@ class Sort extends Object
* Based on the sort direction, the CSS class of the generated hyperlink will be appended
* with "asc" or "desc".
* @param string $attribute the attribute name by which the data should be sorted by.
* @param string $label the label to be used for the generated link.
* If this is null, the label defined in [[attributes]] will be used.
* @param array $options additional HTML attributes for the hyperlink tag.
* There is one special attribute `label` which will be used as the label of the hyperlink.
* If this is not set, the label defined in [[attributes]] will be used.
* If no label is defined, [[yii\helpers\Inflector::camel2words()]] will be called to get a label.
*
@param array $options additional HTML attributes for the hyperlink tag
*
Note that it will not be HTML-encoded.
* @return string the generated hyperlink
* @throws InvalidConfigException if the attribute is unknown
*/
public
function
link
(
$attribute
,
$
label
=
null
,
$
options
=
array
())
public
function
link
(
$attribute
,
$options
=
array
())
{
if
((
$direction
=
$this
->
getAttributeOrder
(
$attribute
))
!==
null
)
{
$class
=
$direction
?
'desc'
:
'asc'
;
...
...
@@ -306,7 +308,10 @@ class Sort extends Object
$url
=
$this
->
createUrl
(
$attribute
);
$options
[
'data-sort'
]
=
$this
->
createSortVar
(
$attribute
);
if
(
$label
===
null
)
{
if
(
isset
(
$options
[
'label'
]))
{
$label
=
$options
[
'label'
];
unset
(
$options
[
'label'
]);
}
else
{
if
(
isset
(
$this
->
attributes
[
$attribute
][
'label'
]))
{
$label
=
$this
->
attributes
[
$attribute
][
'label'
];
}
else
{
...
...
framework/yii/grid/DataColumn.php
View file @
53b4ed3d
...
...
@@ -99,7 +99,7 @@ class DataColumn extends Column
if
(
$this
->
attribute
!==
null
&&
$this
->
enableSorting
&&
(
$sort
=
$provider
->
getSort
())
!==
false
&&
$sort
->
hasAttribute
(
$this
->
attribute
))
{
return
$sort
->
link
(
$this
->
attribute
,
Html
::
encode
(
$label
),
$this
->
sortLinkOptions
);
return
$sort
->
link
(
$this
->
attribute
,
array_merge
(
$this
->
sortLinkOptions
,
array
(
'label'
=>
Html
::
encode
(
$label
)))
);
}
else
{
return
Html
::
encode
(
$label
);
}
...
...
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