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
61841345
Commit
61841345
authored
Apr 23, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3164 from ivan-kolmychek/3154-gridview-filter-error-indication
GridView filter error indication added (#3154)
parents
f1ff318a
bb4e8eb7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
DataColumn.php
framework/grid/DataColumn.php
+3
-0
GridView.php
framework/grid/GridView.php
+41
-0
No files found.
framework/grid/DataColumn.php
View file @
61841345
...
...
@@ -143,6 +143,9 @@ class DataColumn extends Column
return
$this
->
filter
;
}
elseif
(
$this
->
filter
!==
false
&&
$this
->
grid
->
filterModel
instanceof
Model
&&
$this
->
attribute
!==
null
&&
$this
->
grid
->
filterModel
->
isAttributeActive
(
$this
->
attribute
))
{
if
(
$this
->
grid
->
filterModel
->
hasErrors
(
$this
->
attribute
))
{
Html
::
addCssClass
(
$this
->
filterOptions
,
'has-error'
);
}
if
(
is_array
(
$this
->
filter
))
{
$options
=
array_merge
([
'prompt'
=>
''
],
$this
->
filterInputOptions
);
return
Html
::
activeDropDownList
(
$this
->
grid
->
filterModel
,
$this
->
attribute
,
$this
->
filter
,
$options
);
...
...
framework/grid/GridView.php
View file @
61841345
...
...
@@ -15,6 +15,8 @@ use yii\helpers\Url;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\widgets\BaseListView
;
use
yii\helpers\ArrayHelper
;
use
yii\base\Model
;
/**
* The GridView widget is used to display data in a grid.
...
...
@@ -174,6 +176,17 @@ class GridView extends BaseListView
*/
public
$filterRowOptions
=
[
'class'
=>
'filters'
];
/**
* @var string the layout that determines how different sections of the list view should be organized.
* The following tokens will be replaced with the corresponding section contents:
*
* - `{summary}`: the summary section. See [[renderSummary()]].
* - `{error}`: the filter model errors. See [[renderErrors()]].
* - `{items}`: the list items. See [[renderItems()]].
* - `{sorter}`: the sorter. See [[renderSorter()]].
* - `{pager}`: the pager. See [[renderPager()]].
*/
public
$layout
=
"
{
summary}\n{errors}\n{items}\n{pager
}
"
;
/**
* Initializes the grid view.
...
...
@@ -214,6 +227,34 @@ class GridView extends BaseListView
}
/**
* @inheritdoc
*/
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'
]);
}
return
''
;
}
public
function
renderSection
(
$name
)
{
switch
(
$name
)
{
case
"
{
errors
}
"
:
return
$this
->
renderErrors
();
default
:
return
parent
::
renderSection
(
$name
);
}
}
/**
* Returns the options for the grid view JS widget.
* @return array the 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