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
4f6e1d30
Commit
4f6e1d30
authored
Apr 22, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the code for #3154
parent
61841345
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
19 deletions
+15
-19
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
GridView.php
framework/grid/GridView.php
+14
-19
No files found.
framework/CHANGELOG.md
View file @
4f6e1d30
...
...
@@ -24,6 +24,7 @@ Yii Framework 2 Change Log
-
Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
-
Enh #3108: Added
`yii\debug\Module::enableDebugLogs`
to disable logging debug logs by default (qiangxue)
-
Enh #3132:
`yii\rbac\PhpManager`
now supports more compact data file format (qiangxue)
-
Enh #3154: Added validation error display for
`GridView`
filters (ivan-kolmychek)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
framework/grid/GridView.php
View file @
4f6e1d30
...
...
@@ -181,7 +181,7 @@ class GridView extends BaseListView
* The following tokens will be replaced with the corresponding section contents:
*
* - `{summary}`: the summary section. See [[renderSummary()]].
* - `{error}`: the filter model errors. See [[renderErrors()]].
* - `{error
s
}`: the filter model errors. See [[renderErrors()]].
* - `{items}`: the list items. See [[renderItems()]].
* - `{sorter}`: the sorter. See [[renderSorter()]].
* - `{pager}`: the pager. See [[renderPager()]].
...
...
@@ -225,25 +225,20 @@ class GridView extends BaseListView
$view
->
registerJs
(
"jQuery('#
$id
').yiiGridView(
$options
);"
);
parent
::
run
();
}
/**
* @inheritdoc
* Renders validator errors of filter model.
* @return string the rendering result.
*/
public
function
renderErrors
()
{
if
(
$this
->
filterModel
instanceof
Model
&&
$this
->
filterModel
->
hasErrors
())
{
$errorsList
=
[];
foreach
(
$this
->
filterModel
->
errors
as
$attribute
=>
$errors
)
{
$errorsList
=
ArrayHelper
::
merge
(
$errorsList
,
$errors
);
}
return
Html
::
tag
(
'div'
,
Html
::
ul
(
$errorsList
,
[
'class'
=>
'help-block'
]),
[
'class'
=>
'has-error'
]);
if
(
$this
->
filterModel
instanceof
Model
&&
$this
->
filterModel
->
hasErrors
())
{
return
Html
::
tag
(
'div'
,
Html
::
ul
(
$this
->
filterModel
->
getFirstErrors
(),
[
'class'
=>
'help-block'
]),
[
'class'
=>
'has-error'
]);
}
else
{
return
''
;
}
return
''
;
}
public
function
renderSection
(
$name
)
{
switch
(
$name
)
{
...
...
@@ -253,7 +248,7 @@ class GridView extends BaseListView
return
parent
::
renderSection
(
$name
);
}
}
/**
* Returns the options for the grid view JS widget.
* @return array the options
...
...
@@ -351,7 +346,7 @@ class GridView extends BaseListView
$content
.=
$this
->
renderFilters
();
}
return
"<thead>
\n
"
.
$content
.
"
\n
</thead>"
;
return
"<thead>
\n
"
.
$content
.
"
\n
</thead>"
;
}
/**
...
...
@@ -448,7 +443,7 @@ class GridView extends BaseListView
}
else
{
$options
=
$this
->
rowOptions
;
}
$options
[
'data-key'
]
=
is_array
(
$key
)
?
json_encode
(
$key
)
:
(
string
)
$key
;
$options
[
'data-key'
]
=
is_array
(
$key
)
?
json_encode
(
$key
)
:
(
string
)
$key
;
return
Html
::
tag
(
'tr'
,
implode
(
''
,
$cells
),
$options
);
}
...
...
@@ -466,7 +461,7 @@ class GridView extends BaseListView
$column
=
$this
->
createDataColumn
(
$column
);
}
else
{
$column
=
Yii
::
createObject
(
array_merge
([
'class'
=>
$this
->
dataColumnClass
?:
DataColumn
::
className
(),
'class'
=>
$this
->
dataColumnClass
?
:
DataColumn
::
className
(),
'grid'
=>
$this
,
],
$column
));
}
...
...
@@ -491,7 +486,7 @@ class GridView extends BaseListView
}
return
Yii
::
createObject
([
'class'
=>
$this
->
dataColumnClass
?:
DataColumn
::
className
(),
'class'
=>
$this
->
dataColumnClass
?
:
DataColumn
::
className
(),
'grid'
=>
$this
,
'attribute'
=>
$matches
[
1
],
'format'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
'text'
,
...
...
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