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
1e098ebd
Commit
1e098ebd
authored
Apr 02, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified search model [skip ci]
parent
f747768f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
17 deletions
+4
-17
search.php
extensions/gii/generators/crud/default/search.php
+4
-17
No files found.
extensions/gii/generators/crud/default/search.php
View file @
1e098ebd
...
...
@@ -25,17 +25,15 @@ echo "<?php\n";
namespace
<?=
StringHelper
::
dirname
(
ltrim
(
$generator
->
searchModelClass
,
'\\'
))
?>
;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
.
(
isset
(
$modelAlias
)
?
" as
$modelAlias
"
:
""
)
?>
;
/**
*
<?=
$searchModelClass
?>
represents the model behind the search form about `
<?=
$generator
->
modelClass
?>
`.
*/
class
<?=
$searchModelClass
?>
extends Model
{
public $
<?=
implode
(
";
\n
public $"
,
$searchAttributes
)
?>
;
class
<?=
$searchModelClass
?>
extends
<?=
isset
(
$modelAlias
)
?
$modelAlias
:
$modelClass
?>
{
public function rules()
{
return [
...
...
@@ -43,21 +41,10 @@ class <?= $searchModelClass ?> extends Model
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
<?php
foreach
(
$labels
as
$name
=>
$label
)
:
?>
<?=
"'
$name
' => "
.
$generator
->
generateString
(
$label
)
.
",
\n
"
?>
<?php
endforeach
;
?>
];
}
public function search($params)
{
$query =
<?=
isset
(
$modelAlias
)
?
$modelAlias
:
$modelClass
?>
::find();
$query = $this->find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
...
...
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