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
b147760c
Commit
b147760c
authored
Aug 26, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added label option to Sort::link()
parent
a2eb49cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
Sort.php
framework/yii/data/Sort.php
+11
-5
No files found.
framework/yii/data/Sort.php
View file @
b147760c
...
...
@@ -285,11 +285,14 @@ 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]] we be used.
* If there is no label defined, [[Inflector::camel2words()]] will be called to get a label.
* @param array $options additional HTML attributes for the hyperlink tag
* @return string the generated hyperlink
* @throws InvalidConfigException if the attribute is unknown
*/
public
function
link
(
$attribute
,
$options
=
array
())
public
function
link
(
$attribute
,
$
label
=
null
,
$
options
=
array
())
{
if
((
$direction
=
$this
->
getAttributeOrder
(
$attribute
))
!==
null
)
{
$class
=
$direction
?
'desc'
:
'asc'
;
...
...
@@ -302,10 +305,13 @@ class Sort extends Object
$url
=
$this
->
createUrl
(
$attribute
);
$options
[
'data-sort'
]
=
$this
->
createSortVar
(
$attribute
);
if
(
isset
(
$this
->
attributes
[
$attribute
][
'label'
]))
{
$label
=
$this
->
attributes
[
$attribute
][
'label'
];
}
else
{
$label
=
Inflector
::
camel2words
(
$attribute
);
if
(
$label
===
null
)
{
if
(
isset
(
$this
->
attributes
[
$attribute
][
'label'
]))
{
$label
=
$this
->
attributes
[
$attribute
][
'label'
];
}
else
{
$label
=
Inflector
::
camel2words
(
$attribute
);
}
}
return
Html
::
a
(
$label
,
$url
,
$options
);
}
...
...
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