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
e299b78a
Commit
e299b78a
authored
Jan 21, 2014
by
Thiago Talma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Best way to get the labels to search, the existing model.
parent
48448864
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
Generator.php
extensions/gii/generators/crud/Generator.php
+12
-6
No files found.
extensions/gii/generators/crud/Generator.php
View file @
e299b78a
...
@@ -305,16 +305,22 @@ class Generator extends \yii\gii\Generator
...
@@ -305,16 +305,22 @@ class Generator extends \yii\gii\Generator
*/
*/
public
function
generateSearchLabels
()
public
function
generateSearchLabels
()
{
{
$model
=
new
$this
->
modelClass
();
$attributeLabels
=
$model
->
attributeLabels
();
$labels
=
[];
$labels
=
[];
foreach
(
$this
->
getColumnNames
()
as
$name
)
{
foreach
(
$this
->
getColumnNames
()
as
$name
)
{
if
(
!
strcasecmp
(
$name
,
'id'
))
{
if
(
isset
(
$attributeLabels
[
$name
]
))
{
$labels
[
$name
]
=
'ID'
;
$labels
[
$name
]
=
$attributeLabels
[
$name
]
;
}
else
{
}
else
{
$label
=
Inflector
::
camel2words
(
$name
);
if
(
!
strcasecmp
(
$name
,
'id'
))
{
if
(
strcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
$labels
[
$name
]
=
'ID'
;
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$name
);
if
(
strcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
$labels
[
$name
]
=
$label
;
}
}
$labels
[
$name
]
=
$label
;
}
}
}
}
return
$labels
;
return
$labels
;
...
...
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