Commit e299b78a by Thiago Talma

Best way to get the labels to search, the existing model.

parent 48448864
...@@ -305,8 +305,13 @@ class Generator extends \yii\gii\Generator ...@@ -305,8 +305,13 @@ 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 (isset($attributeLabels[$name])) {
$labels[$name] = $attributeLabels[$name];
} else {
if (!strcasecmp($name, 'id')) { if (!strcasecmp($name, 'id')) {
$labels[$name] = 'ID'; $labels[$name] = 'ID';
} else { } else {
...@@ -317,6 +322,7 @@ class Generator extends \yii\gii\Generator ...@@ -317,6 +322,7 @@ class Generator extends \yii\gii\Generator
$labels[$name] = $label; $labels[$name] = $label;
} }
} }
}
return $labels; return $labels;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment