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
*/
public function generateSearchLabels()
{
$model = new $this->modelClass();
$attributeLabels = $model->attributeLabels();
$labels = [];
foreach ($this->getColumnNames() as $name) {
if (isset($attributeLabels[$name])) {
$labels[$name] = $attributeLabels[$name];
} else {
if (!strcasecmp($name, 'id')) {
$labels[$name] = 'ID';
} else {
......@@ -317,6 +322,7 @@ class Generator extends \yii\gii\Generator
$labels[$name] = $label;
}
}
}
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