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
3d1d7f72
Commit
3d1d7f72
authored
Feb 25, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2544: Changed `DetailView`'s `name:format:label` to…
Fixes #2544: Changed `DetailView`'s `name:format:label` to `attribute:format:label` to match `GridView`
parent
03b2fc3e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
DetailView.php
framework/widgets/DetailView.php
+10
-10
No files found.
framework/CHANGELOG.md
View file @
3d1d7f72
...
...
@@ -172,6 +172,7 @@ Yii Framework 2 Change Log
-
Chg #2281: Renamed
`ActiveRecord::create()`
to
`populateRecord()`
and changed signature. This method will not call instantiate() anymore (cebe)
-
Chg #2405: The CSS class of
`MaskedInput`
now defaults to
`form-control`
(qiangxue)
-
Chg #2426: Changed URL creation method signatures to be consistent (samdark)
-
Chg #2544: Changed
`DetailView`
's
`name:format:label`
to
`attribute:format:label`
to match
`GridView`
(samdark)
-
Chg: Renamed
`yii\jui\Widget::clientEventsMap`
to
`clientEventMap`
(qiangxue)
-
Chg: Renamed
`ActiveRecord::getPopulatedRelations()`
to
`getRelatedRecords()`
(qiangxue)
-
Chg: Renamed
`attributeName`
and
`className`
to
`targetAttribute`
and
`targetClass`
for
`UniqueValidator`
and
`ExistValidator`
(qiangxue)
...
...
framework/widgets/DetailView.php
View file @
3d1d7f72
...
...
@@ -57,15 +57,15 @@ class DetailView extends Widget
* @var array a list of attributes to be displayed in the detail view. Each array element
* represents the specification for displaying one particular attribute.
*
* An attribute can be specified as a string in the format of "
name", "name:format" or "nam
e:format:label",
* where "
nam
e" refers to the attribute name, and "format" represents the format of the attribute. The "format"
* An attribute can be specified as a string in the format of "
attribute", "attribute:format" or "attribut
e:format:label",
* where "
attribut
e" refers to 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. Both "format" and "label" are optional.
* They will take default values if absent.
*
* An attribute can also be specified in terms of an array with the following elements:
*
* -
nam
e: the attribute name. This is required if either "label" or "value" is not specified.
* -
attribut
e: the attribute name. This is required if either "label" or "value" is not specified.
* - 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
* by calling [[ArrayHelper::getValue()]]. Note that this value will be formatted into a displayable text
...
...
@@ -176,10 +176,10 @@ class DetailView extends Widget
foreach
(
$this
->
attributes
as
$i
=>
$attribute
)
{
if
(
is_string
(
$attribute
))
{
if
(
!
preg_match
(
'/^([\w\.]+)(:(\w*))?(:(.*))?$/'
,
$attribute
,
$matches
))
{
throw
new
InvalidConfigException
(
'The attribute must be specified in the format of "
name", "name:format" or "nam
e:format:label"'
);
throw
new
InvalidConfigException
(
'The attribute must be specified in the format of "
attribute", "attribute:format" or "attribut
e:format:label"'
);
}
$attribute
=
[
'
nam
e'
=>
$matches
[
1
],
'
attribut
e'
=>
$matches
[
1
],
'format'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
'label'
=>
isset
(
$matches
[
5
])
?
$matches
[
5
]
:
null
,
];
...
...
@@ -197,16 +197,16 @@ class DetailView extends Widget
if
(
!
isset
(
$attribute
[
'format'
]))
{
$attribute
[
'format'
]
=
'text'
;
}
if
(
isset
(
$attribute
[
'
nam
e'
]))
{
$
name
=
$attribute
[
'nam
e'
];
if
(
isset
(
$attribute
[
'
attribut
e'
]))
{
$
attributeName
=
$attribute
[
'attribut
e'
];
if
(
!
isset
(
$attribute
[
'label'
]))
{
$attribute
[
'label'
]
=
$this
->
model
instanceof
Model
?
$this
->
model
->
getAttributeLabel
(
$
name
)
:
Inflector
::
camel2words
(
$n
ame
,
true
);
$attribute
[
'label'
]
=
$this
->
model
instanceof
Model
?
$this
->
model
->
getAttributeLabel
(
$
attributeName
)
:
Inflector
::
camel2words
(
$attributeN
ame
,
true
);
}
if
(
!
array_key_exists
(
'value'
,
$attribute
))
{
$attribute
[
'value'
]
=
ArrayHelper
::
getValue
(
$this
->
model
,
$
n
ame
);
$attribute
[
'value'
]
=
ArrayHelper
::
getValue
(
$this
->
model
,
$
attributeN
ame
);
}
}
elseif
(
!
isset
(
$attribute
[
'label'
])
||
!
array_key_exists
(
'value'
,
$attribute
))
{
throw
new
InvalidConfigException
(
'The attribute configuration requires the "
nam
e" element to determine the value and display label.'
);
throw
new
InvalidConfigException
(
'The attribute configuration requires the "
attribut
e" element to determine the value and display label.'
);
}
$this
->
attributes
[
$i
]
=
$attribute
;
...
...
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