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
e3784e45
Commit
e3784e45
authored
Nov 21, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1277 from cebe/grid-detail-view-consistency
Renamed DetailView attribute "type" to "format"
parents
f3ab5d99
c7ef701d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
DetailView.php
framework/yii/widgets/DetailView.php
+9
-9
No files found.
framework/yii/widgets/DetailView.php
View file @
e3784e45
...
@@ -57,8 +57,8 @@ class DetailView extends Widget
...
@@ -57,8 +57,8 @@ class DetailView extends Widget
* @var array a list of attributes to be displayed in the detail view. Each array element
* @var array a list of attributes to be displayed in the detail view. Each array element
* represents the specification for displaying one particular attribute.
* represents the specification for displaying one particular attribute.
*
*
* An attribute can be specified as a string in the format of "Name" or "Name:
Type
", where "Name" refers to
* An attribute can be specified as a string in the format of "Name" or "Name:
Format
", where "Name" refers to
* the attribute name, and "
Type" represents the type of the attribute. The "Type
" is passed to the [[Formatter::format()]]
* the attribute name, and "
Format" represents the format of the attribute. The "Format
" is passed to the [[Formatter::format()]]
* method to format an attribute value into a displayable text. Please refer to [[Formatter]] for the supported types.
* method to format an attribute value into a displayable text. Please refer to [[Formatter]] for the supported types.
*
*
* An attribute can also be specified in terms of an array with the following elements:
* An attribute can also be specified in terms of an array with the following elements:
...
@@ -67,8 +67,8 @@ class DetailView extends Widget
...
@@ -67,8 +67,8 @@ class DetailView extends Widget
* - label: the label associated with the attribute. If this is not specified, it will be generated from the attribute name.
* - label: the label associated with the attribute. If this is not specified, it will be generated from the attribute name.
* - value: the value to be displayed. If this is not specified, it will be retrieved from [[model]] using the attribute name
* - value: the value to be displayed. If this is not specified, it will be retrieved from [[model]] using the attribute name
* by calling [[ArrayHelper::getValue()]]. Note that this value will be formatted into a displayable text
* by calling [[ArrayHelper::getValue()]]. Note that this value will be formatted into a displayable text
* according to the "
type
" option.
* according to the "
format
" option.
* -
type
: the type of the value that determines how the value would be formatted into a displayable text.
* -
format
: the type of the value that determines how the value would be formatted into a displayable text.
* Please refer to [[Formatter]] for supported types.
* Please refer to [[Formatter]] for supported types.
* - visible: whether the attribute is visible. If set to `false`, the attribute will be displayed.
* - visible: whether the attribute is visible. If set to `false`, the attribute will be displayed.
*/
*/
...
@@ -145,7 +145,7 @@ class DetailView extends Widget
...
@@ -145,7 +145,7 @@ class DetailView extends Widget
if
(
is_string
(
$this
->
template
))
{
if
(
is_string
(
$this
->
template
))
{
return
strtr
(
$this
->
template
,
[
return
strtr
(
$this
->
template
,
[
'{label}'
=>
$attribute
[
'label'
],
'{label}'
=>
$attribute
[
'label'
],
'{value}'
=>
$this
->
formatter
->
format
(
$attribute
[
'value'
],
$attribute
[
'
type
'
]),
'{value}'
=>
$this
->
formatter
->
format
(
$attribute
[
'value'
],
$attribute
[
'
format
'
]),
]);
]);
}
else
{
}
else
{
return
call_user_func
(
$this
->
template
,
$attribute
,
$index
,
$this
);
return
call_user_func
(
$this
->
template
,
$attribute
,
$index
,
$this
);
...
@@ -174,11 +174,11 @@ class DetailView extends Widget
...
@@ -174,11 +174,11 @@ class DetailView extends Widget
foreach
(
$this
->
attributes
as
$i
=>
$attribute
)
{
foreach
(
$this
->
attributes
as
$i
=>
$attribute
)
{
if
(
is_string
(
$attribute
))
{
if
(
is_string
(
$attribute
))
{
if
(
!
preg_match
(
'/^(\w+)(\s*:\s*(\w+))?$/'
,
$attribute
,
$matches
))
{
if
(
!
preg_match
(
'/^(\w+)(\s*:\s*(\w+))?$/'
,
$attribute
,
$matches
))
{
throw
new
InvalidConfigException
(
'The attribute must be specified in the format of "Name" or "Name:
Type
"'
);
throw
new
InvalidConfigException
(
'The attribute must be specified in the format of "Name" or "Name:
Format
"'
);
}
}
$attribute
=
[
$attribute
=
[
'name'
=>
$matches
[
1
],
'name'
=>
$matches
[
1
],
'
type
'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
'
format
'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
];
];
}
}
...
@@ -186,8 +186,8 @@ class DetailView extends Widget
...
@@ -186,8 +186,8 @@ class DetailView extends Widget
throw
new
InvalidConfigException
(
'The attribute configuration must be an array.'
);
throw
new
InvalidConfigException
(
'The attribute configuration must be an array.'
);
}
}
if
(
!
isset
(
$attribute
[
'
type
'
]))
{
if
(
!
isset
(
$attribute
[
'
format
'
]))
{
$attribute
[
'
type
'
]
=
'text'
;
$attribute
[
'
format
'
]
=
'text'
;
}
}
if
(
isset
(
$attribute
[
'name'
]))
{
if
(
isset
(
$attribute
[
'name'
]))
{
$name
=
$attribute
[
'name'
];
$name
=
$attribute
[
'name'
];
...
...
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