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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
ce4bf844
Commit
ce4bf844
authored
Oct 10, 2014
by
Alexey Kolmakov
Committed by
Alexander Makarov
Oct 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#5467 Allow pass options to Html:a in Formatter:asUrl
parent
6c6afd3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
Formatter.php
framework/i18n/Formatter.php
+3
-2
FormatterTest.php
tests/unit/framework/i18n/FormatterTest.php
+2
-0
No files found.
framework/i18n/Formatter.php
View file @
ce4bf844
...
...
@@ -359,9 +359,10 @@ class Formatter extends Component
/**
* Formats the value as a hyperlink.
* @param mixed $value the value to be formatted.
* @param array $options the tag options in terms of name-value pairs. See [[Html::a()]].
* @return string the formatted result.
*/
public
function
asUrl
(
$value
)
public
function
asUrl
(
$value
,
$options
=
[]
)
{
if
(
$value
===
null
)
{
return
$this
->
nullDisplay
;
...
...
@@ -371,7 +372,7 @@ class Formatter extends Component
$url
=
'http://'
.
$url
;
}
return
Html
::
a
(
Html
::
encode
(
$value
),
$url
);
return
Html
::
a
(
Html
::
encode
(
$value
),
$url
,
$options
);
}
/**
...
...
tests/unit/framework/i18n/FormatterTest.php
View file @
ce4bf844
...
...
@@ -158,6 +158,8 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
"<a href=
\"
http://
$value
\"
>
$value
</a>"
,
$this
->
formatter
->
asUrl
(
$value
));
$value
=
'https://www.yiiframework.com/?name=test&value=5"'
;
$this
->
assertSame
(
"<a href=
\"
https://www.yiiframework.com/?name=test&value=5"
\"
>https://www.yiiframework.com/?name=test&value=5"</a>"
,
$this
->
formatter
->
asUrl
(
$value
));
$value
=
'http://www.yiiframework.com/'
;
$this
->
assertSame
(
"<a href=
\"
$value
\"
target=
\"
_blank
\"
>
$value
</a>"
,
$this
->
formatter
->
asUrl
(
$value
,
[
'target'
=>
'_blank'
]));
// null display
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asUrl
(
null
));
...
...
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