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
08791481
Commit
08791481
authored
Jun 10, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3775 from Ragazzo/widgets_guide_adjusted
fixed note about search class
parents
3f5e6e9b
8e1ba127
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
output-data-widgets.md
docs/guide/output-data-widgets.md
+4
-4
No files found.
docs/guide/output-data-widgets.md
View file @
08791481
...
@@ -231,8 +231,8 @@ echo GridView::widget([
...
@@ -231,8 +231,8 @@ echo GridView::widget([
For filtering data the GridView needs a
[
model
](
model.md
)
that takes the input from the filtering
For filtering data the GridView needs a
[
model
](
model.md
)
that takes the input from the filtering
form and adjusts the query of the dataProvider to respect the search criteria.
form and adjusts the query of the dataProvider to respect the search criteria.
A common practice when using
[
active records
](
active-record.md
)
is to create a search Model class
A common practice when using
[
active records
](
active-record.md
)
is to create a search Model class
that
extends from the active record class. This class then defines the validation rules for the search
that
provides needed functionality (it can be generated for you by Gii). This class defines the validation
and provides a
`search()`
method that will return the data provider.
rules for the search
and provides a
`search()`
method that will return the data provider.
To add search capability for the
`Post`
model we can create
`PostSearch`
like in the following example:
To add search capability for the
`Post`
model we can create
`PostSearch`
like in the following example:
...
@@ -245,7 +245,7 @@ use Yii;
...
@@ -245,7 +245,7 @@ use Yii;
use
yii\base\Model
;
use
yii\base\Model
;
use
yii\data\ActiveDataProvider
;
use
yii\data\ActiveDataProvider
;
class
PostSearch
extends
Post
class
PostSearch
extends
Model
{
{
public
function
rules
()
public
function
rules
()
{
{
...
@@ -290,7 +290,7 @@ You can use this function in the controller to get the dataProvider for the Grid
...
@@ -290,7 +290,7 @@ You can use this function in the controller to get the dataProvider for the Grid
```
php
```
php
$searchModel
=
new
PostSearch
();
$searchModel
=
new
PostSearch
();
$dataProvider
=
$searchModel
->
search
(
$_GET
);
$dataProvider
=
$searchModel
->
search
(
Yii
::
$app
->
request
->
get
()
);
return
$this
->
render
(
'myview'
,
[
return
$this
->
render
(
'myview'
,
[
'dataProvider'
=>
$dataProvider
,
'dataProvider'
=>
$dataProvider
,
...
...
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