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
c5022203
Commit
c5022203
authored
Jan 16, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue with null value in CRUD controller findModel()
parent
74a74c84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
CHANGELOG.md
extensions/gii/CHANGELOG.md
+1
-0
controller.php
extensions/gii/generators/crud/templates/controller.php
+4
-1
No files found.
extensions/gii/CHANGELOG.md
View file @
c5022203
...
@@ -5,6 +5,7 @@ Yii Framework 2 gii extension Change Log
...
@@ -5,6 +5,7 @@ Yii Framework 2 gii extension Change Log
----------------------------
----------------------------
-
Bug #1405: fixed disambiguation of relation names generated by gii (qiangxue)
-
Bug #1405: fixed disambiguation of relation names generated by gii (qiangxue)
-
Bug: fixed controller in crud template to avoid returning query in findModel() (cebe)
-
Enh #1624: generate rules for unique indexes (lucianobaraglia)
-
Enh #1624: generate rules for unique indexes (lucianobaraglia)
-
Enh #1818: Do not display checkbox column if all rows are empty (johonunu)
-
Enh #1818: Do not display checkbox column if all rows are empty (johonunu)
...
...
extensions/gii/generators/crud/templates/controller.php
View file @
c5022203
...
@@ -140,15 +140,18 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
...
@@ -140,15 +140,18 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
<?php
<?php
if
(
count
(
$pks
)
===
1
)
{
if
(
count
(
$pks
)
===
1
)
{
$condition
=
'$id'
;
$condition
=
'$id'
;
// find() would return Query when $id === null
$nullCheck
=
'$id !== null && '
;
}
else
{
}
else
{
$condition
=
[];
$condition
=
[];
foreach
(
$pks
as
$pk
)
{
foreach
(
$pks
as
$pk
)
{
$condition
[]
=
"'
$pk
' =>
\$
$pk
"
;
$condition
[]
=
"'
$pk
' =>
\$
$pk
"
;
}
}
$condition
=
'['
.
implode
(
', '
,
$condition
)
.
']'
;
$condition
=
'['
.
implode
(
', '
,
$condition
)
.
']'
;
$nullCheck
=
''
;
}
}
?>
?>
if (($model =
<?=
$modelClass
?>
::find(
<?=
$condition
?>
)) !== null) {
if (
<?=
$nullCheck
?>
($model =
<?=
$modelClass
?>
::find(
<?=
$condition
?>
)) !== null) {
return $model;
return $model;
} else {
} else {
throw new NotFoundHttpException('The requested page does not exist.');
throw new NotFoundHttpException('The requested page does not exist.');
...
...
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