From 4cbdd7a6dd0d6e186d13e453257865506f5899c7 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 9 Sep 2013 23:36:44 -0400 Subject: [PATCH] crud WIP --- framework/yii/gii/assets/gii.js | 5 - framework/yii/gii/generators/crud/Generator.php | 208 +++++++++++++++++---- framework/yii/gii/generators/crud/form.php | 3 +- .../gii/generators/crud/templates/controller.php | 69 +++---- .../yii/gii/generators/crud/templates/search.php | 85 ++++++++- .../gii/generators/crud/templates/views/_form.php | 5 +- .../generators/crud/templates/views/_search.php | 59 +++--- .../gii/generators/crud/templates/views/create.php | 2 + .../gii/generators/crud/templates/views/index.php | 49 +++-- .../gii/generators/crud/templates/views/update.php | 5 + .../gii/generators/crud/templates/views/view.php | 13 +- framework/yii/gii/views/default/view.php | 2 +- 12 files changed, 362 insertions(+), 143 deletions(-) diff --git a/framework/yii/gii/assets/gii.js b/framework/yii/gii/assets/gii.js index 45951a1..b581d3b 100644 --- a/framework/yii/gii/assets/gii.js +++ b/framework/yii/gii/assets/gii.js @@ -81,11 +81,6 @@ yii.gii = (function ($) { $('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1); }).change(); - // crud generator: hide Search Model Class input if search is not enabled - $('#crud-generator #generator-enablesearch').on('change', function () { - $('#crud-generator .field-generator-searchmodelclass').toggle(this.checked); - }).change(); - // hide Generate button if any input is changed $('.default-view .form-group input,select,textarea').change(function () { $('.default-view-results,.default-view-files').hide(); diff --git a/framework/yii/gii/generators/crud/Generator.php b/framework/yii/gii/generators/crud/Generator.php index 7f1bff0..9bce7ff 100644 --- a/framework/yii/gii/generators/crud/Generator.php +++ b/framework/yii/gii/generators/crud/Generator.php @@ -10,6 +10,7 @@ namespace yii\gii\generators\crud; use Yii; use yii\base\Model; use yii\db\ActiveRecord; +use yii\db\Schema; use yii\gii\CodeFile; use yii\helpers\Inflector; use yii\web\Controller; @@ -26,7 +27,6 @@ class Generator extends \yii\gii\Generator public $controllerClass; public $baseControllerClass = 'yii\web\Controller'; public $indexWidgetType = 'grid'; - public $enableSearch = true; public $searchModelClass; public function getName() @@ -44,16 +44,14 @@ class Generator extends \yii\gii\Generator { return array_merge(parent::rules(), array( array('moduleID, controllerClass, modelClass, searchModelClass, baseControllerClass', 'filter', 'filter' => 'trim'), - array('modelClass, controllerClass, baseControllerClass, indexWidgetType', 'required'), + array('modelClass, searchModelClass, controllerClass, baseControllerClass, indexWidgetType', 'required'), array('modelClass, controllerClass, baseControllerClass, searchModelClass', 'match', 'pattern' => '/^[\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'), array('modelClass', 'validateClass', 'params' => array('extends' => ActiveRecord::className())), array('baseControllerClass', 'validateClass', 'params' => array('extends' => Controller::className())), array('controllerClass', 'match', 'pattern' => '/Controller$/', 'message' => 'Controller class name must be suffixed with "Controller".'), array('controllerClass, searchModelClass', 'validateNewClass'), - array('enableSearch', 'boolean'), array('indexWidgetType', 'in', 'range' => array('grid', 'list')), array('modelClass', 'validateModelClass'), - array('searchModelClass', 'validateSearchModelClass'), array('moduleID', 'validateModuleID'), )); } @@ -66,7 +64,6 @@ class Generator extends \yii\gii\Generator 'controllerClass' => 'Controller Class', 'baseControllerClass' => 'Base Controller Class', 'indexWidgetType' => 'Widget Used in Index Page', - 'enableSearch' => 'Enable Search', 'searchModelClass' => 'Search Model Class', )); } @@ -87,11 +84,8 @@ class Generator extends \yii\gii\Generator If not set, it means the controller will belong to the application.', 'indexWidgetType' => 'This is the widget type to be used in the index page to display list of the models. You may choose either GridView or ListView', - 'enableSearch' => 'Whether to enable the search functionality on the index page. When search is enabled, - a search form will be displayed on the index page, and the index page will display the search results.', 'searchModelClass' => 'This is the class representing the data being collecting in the search form. - A fully qualified namespaced class name is required, e.g., app\models\PostSearchForm. - This is only used when search is enabled.', + A fully qualified namespaced class name is required, e.g., app\models\search\PostSearch.', ); } @@ -107,7 +101,7 @@ class Generator extends \yii\gii\Generator */ public function stickyAttributes() { - return array('baseControllerClass', 'moduleID', 'indexWidgetType', 'enableSearch'); + return array('baseControllerClass', 'moduleID', 'indexWidgetType'); } public function validateModelClass() @@ -120,13 +114,6 @@ class Generator extends \yii\gii\Generator } } - public function validateSearchModelClass() - { - if ($this->enableSearch && empty($this->searchModelClass)) { - $this->addError('searchModelClass', 'Search Model Class cannot be empty.'); - } - } - public function validateModuleID() { if (!empty($this->moduleID)) { @@ -142,26 +129,21 @@ class Generator extends \yii\gii\Generator */ public function generate() { - $files = array(); - $files[] = new CodeFile( - $this->getControllerFile(), - $this->render('controller.php') + $controllerFile = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php'); + $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); + $files = array( + new CodeFile($controllerFile, $this->render('controller.php')), + new CodeFile($searchModel, $this->render('search.php')), ); - $viewPath = $this->getViewPath(); + $viewPath = $this->getViewPath(); $templatePath = $this->getTemplatePath() . '/views'; foreach (scandir($templatePath) as $file) { - if (!in_array($file, array('index.php', 'create.php', 'update.php', 'view.php', '_form.php'))) { - continue; - } if (is_file($templatePath . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { $files[] = new CodeFile("$viewPath/$file", $this->render("views/$file")); } } - if ($this->enableSearch) { - - } return $files; } @@ -177,14 +159,6 @@ class Generator extends \yii\gii\Generator } /** - * @return string the controller class file path - */ - public function getControllerFile() - { - return Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php'); - } - - /** * @return string the action view file path */ public function getViewPath() @@ -207,13 +181,12 @@ class Generator extends \yii\gii\Generator } /** - * @param ActiveRecord $model * @param string $attribute * @return string */ - public function generateActiveField($model, $attribute) + public function generateActiveField($attribute) { - $tableSchema = $model->getTableSchema(); + $tableSchema = $this->getTableSchema(); if (!isset($tableSchema->columns[$attribute])) { return "\$form->field(\$model, '$attribute');"; } @@ -237,6 +210,21 @@ class Generator extends \yii\gii\Generator } /** + * @param string $attribute + * @return string + */ + public function generateActiveSearchField($attribute) + { + $tableSchema = $this->getTableSchema(); + $column = $tableSchema->columns[$attribute]; + if ($column->phpType === 'boolean') { + return "\$form->field(\$model, '$attribute')->checkbox();"; + } else { + return "\$form->field(\$model, '$attribute');"; + } + } + + /** * @param \yii\db\ColumnSchema $column * @return string */ @@ -256,4 +244,146 @@ class Generator extends \yii\gii\Generator return 'text'; } } + + /** + * Generates validation rules for the search model. + * @return array the generated validation rules + */ + public function generateSearchRules() + { + $table = $this->getTableSchema(); + $types = array(); + foreach ($table->columns as $column) { + switch ($column->type) { + case Schema::TYPE_SMALLINT: + case Schema::TYPE_INTEGER: + case Schema::TYPE_BIGINT: + $types['integer'][] = $column->name; + break; + case Schema::TYPE_BOOLEAN: + $types['boolean'][] = $column->name; + break; + case Schema::TYPE_FLOAT: + case Schema::TYPE_DECIMAL: + case Schema::TYPE_MONEY: + $types['number'][] = $column->name; + break; + case Schema::TYPE_DATE: + case Schema::TYPE_TIME: + case Schema::TYPE_DATETIME: + case Schema::TYPE_TIMESTAMP: + default: + $types['safe'][] = $column->name; + break; + } + } + + $rules = array(); + foreach ($types as $type => $columns) { + $rules[] = "array('" . implode(', ', $columns) . "', '$type')"; + } + + return $rules; + } + + public function getSearchAttributes() + { + return $this->getTableSchema()->getColumnNames(); + } + + /** + * Generates the attribute labels for the search model. + * @return array the generated attribute labels (name => label) + */ + public function generateSearchLabels() + { + $table = $this->getTableSchema(); + $labels = array(); + foreach ($table->columns as $column) { + if (!strcasecmp($column->name, 'id')) { + $labels[$column->name] = 'ID'; + } else { + $label = Inflector::camel2words($column->name); + if (strcasecmp(substr($label, -3), ' id') === 0) { + $label = substr($label, 0, -3) . ' ID'; + } + $labels[$column->name] = $label; + } + } + return $labels; + } + + public function generateSearchConditions() + { + $table = $this->getTableSchema(); + $conditions = array(); + foreach ($table->columns as $column) { + switch ($column->type) { + case Schema::TYPE_SMALLINT: + case Schema::TYPE_INTEGER: + case Schema::TYPE_BIGINT: + case Schema::TYPE_BOOLEAN: + case Schema::TYPE_FLOAT: + case Schema::TYPE_DECIMAL: + case Schema::TYPE_MONEY: + case Schema::TYPE_DATE: + case Schema::TYPE_TIME: + case Schema::TYPE_DATETIME: + case Schema::TYPE_TIMESTAMP: + $conditions[] = "\$this->addCondition(\$query, '{$column->name}');"; + break; + default: + $conditions[] = "\$this->addCondition(\$query, '{$column->name}', true);"; + break; + } + } + + return $conditions; + } + + public function generateUrlParams() + { + $pks = $this->getTableSchema()->primaryKey; + if (count($pks) === 1) { + return "'id' => \$model->{$pks[0]}"; + } else { + $params = array(); + foreach ($pks as $pk) { + $params[] = "'$pk' => \$model->$pk"; + } + return implode(', ', $params); + } + } + + public function generateActionParams() + { + $pks = $this->getTableSchema()->primaryKey; + if (count($pks) === 1) { + return '$id'; + } else { + return '$' . implode(', $', $pks); + } + } + + public function generateActionParamComments() + { + $table = $this->getTableSchema(); + $pks = $table->primaryKey; + if (count($pks) === 1) { + return array('@param ' . $table->columns[$pks[0]]->phpType . ' $id'); + } else { + $params = array(); + foreach ($pks as $pk) { + $params[] = '@param ' . $table->columns[$pk]->phpType . ' $' . $pk; + } + return $params; + } + } + + public function getTableSchema() + { + /** @var ActiveRecord $class */ + $class = $this->modelClass; + return $class::getTableSchema(); + } } diff --git a/framework/yii/gii/generators/crud/form.php b/framework/yii/gii/generators/crud/form.php index ee4771b..829b8a3 100644 --- a/framework/yii/gii/generators/crud/form.php +++ b/framework/yii/gii/generators/crud/form.php @@ -6,11 +6,10 @@ */ echo $form->field($generator, 'modelClass'); +echo $form->field($generator, 'searchModelClass'); echo $form->field($generator, 'controllerClass'); echo $form->field($generator, 'baseControllerClass'); echo $form->field($generator, 'moduleID'); -echo $form->field($generator, 'enableSearch')->checkbox(); -echo $form->field($generator, 'searchModelClass'); echo $form->field($generator, 'indexWidgetType')->dropDownList(array( 'grid' => 'GridView', 'list' => 'ListView', diff --git a/framework/yii/gii/generators/crud/templates/controller.php b/framework/yii/gii/generators/crud/templates/controller.php index da915c8..fd33eda 100644 --- a/framework/yii/gii/generators/crud/templates/controller.php +++ b/framework/yii/gii/generators/crud/templates/controller.php @@ -9,38 +9,22 @@ use yii\helpers\StringHelper; * @var yii\gii\generators\crud\Generator $generator */ -$pos = strrpos($generator->controllerClass, '\\'); -$ns = ltrim(substr($generator->controllerClass, 0, $pos), '\\'); -$controllerClass = substr($generator->controllerClass, $pos + 1); -$pos = strrpos($generator->modelClass, '\\'); -$modelClass = $pos === false ? $generator->modelClass : substr($generator->modelClass, $pos + 1); - -/** @var \yii\db\ActiveRecord $class */ -$class = $generator->modelClass; -$pks = $class::primaryKey(); -$schema = $class::getTableSchema(); -if (count($pks) === 1) { - $ids = '$id'; - $params = "array('id' => \$model->{$pks[0]})"; - $paramComments = '@param ' . $schema->columns[$pks[0]]->phpType . ' $id'; -} else { - $ids = '$' . implode(', $', $pks); - $params = array(); - $paramComments = array(); - foreach ($pks as $pk) { - $paramComments[] = '@param ' . $schema->columns[$pk]->phpType . ' $' . $pk; - $params[] = "'$pk' => \$model->$pk"; - } - $params = implode(', ', $params); - $paramComments = implode("\n\t * ", $paramComments); -} +$controllerClass = StringHelper::basename($generator->controllerClass); +$modelClass = StringHelper::basename($generator->modelClass); +$searchModelClass = StringHelper::basename($generator->searchModelClass); + +$pks = $generator->getTableSchema()->primaryKey; +$urlParams = $generator->generateUrlParams(); +$actionParams = $generator->generateActionParams(); +$actionParamComments = $generator->generateActionParamComments(); echo " -namespace ; +namespace controllerClass, '\\')); ?>; use modelClass, '\\'); ?>; +use searchModelClass, '\\'); ?>; use yii\data\ActiveDataProvider; use baseControllerClass, '\\'); ?>; use yii\web\HttpException; @@ -56,23 +40,24 @@ class extends ::find(), - )); + $searchModel = new ; + $dataProvider = $searchModel->search($_GET); + return $this->render('index', array( 'dataProvider' => $dataProvider, + 'searchModel' => $searchModel, )); } /** * Displays a single model. - * + * * @return mixed */ - public function actionView() + public function actionView() { return $this->render('view', array( - 'model' => $this->findModel(), + 'model' => $this->findModel(), )); } @@ -86,7 +71,7 @@ class extends ; if ($model->load($_POST) && $model->save()) { - return $this->redirect(array('view', )); + return $this->redirect(array('view', )); } else { return $this->render('create', array( 'model' => $model, @@ -97,15 +82,15 @@ class extends model. * If update is successful, the browser will be redirected to the 'view' page. - * + * * @return mixed */ - public function actionUpdate() + public function actionUpdate() { - $model = $this->findModel(); + $model = $this->findModel(); if ($model->load($_POST) && $model->save()) { - return $this->redirect(array('view', )); + return $this->redirect(array('view', )); } else { return $this->render('update', array( 'model' => $model, @@ -116,23 +101,23 @@ class extends model. * If deletion is successful, the browser will be redirected to the 'index' page. - * + * * @return mixed */ - public function actionDelete() + public function actionDelete() { - $this->findModel()->delete(); + $this->findModel()->delete(); return $this->redirect(array('index')); } /** * Finds the model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. - * + * * @return the loaded model * @throws HttpException if the model cannot be found */ - protected function findModel() + protected function findModel() { modelClass); +$searchModelClass = StringHelper::basename($generator->searchModelClass); +$rules = $generator->generateSearchRules(); +$labels = $generator->generateSearchLabels(); +$searchAttributes = $generator->getSearchAttributes(); +$searchConditions = $generator->generateSearchConditions(); + +echo " + +namespace searchModelClass, '\\')); ?>; + +use yii\base\Model; +use yii\data\ActiveDataProvider; +use modelClass, '\\'); ?>; + +/** + * represents the model behind the search form about . + */ +class extends Model +{ + public $; + + public function rules() + { + return array( + , + ); + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return array( + $label): ?> + '" . addslashes($label) . "',\n"; ?> + + ); + } + + public function search($params) + { + $query = ::find(); + $dataProvider = new ActiveDataProvider(array( + 'query' => $query, + )); + + if (!($this->load($params) && $this->validate())) { + return $dataProvider; + } + + + + return $dataProvider; + } + + protected function addCondition($query, $attribute, $partialMatch = false) + { + $value = $this->$attribute; + if (trim($value) === '') { + return; + } + if ($partialMatch) { + $value = '%' . strtr($value, array('%'=>'\%', '_'=>'\_', '\\'=>'\\\\')) . '%'; + $query->andWhere(array('like', $attribute, $value)); + } else { + $query->andWhere(array($attribute => $value)); + } + } +} diff --git a/framework/yii/gii/generators/crud/templates/views/_form.php b/framework/yii/gii/generators/crud/templates/views/_form.php index 6160e72..2d9d5dc 100644 --- a/framework/yii/gii/generators/crud/templates/views/_form.php +++ b/framework/yii/gii/generators/crud/templates/views/_form.php @@ -9,8 +9,7 @@ use yii\helpers\StringHelper; */ /** @var \yii\db\ActiveRecord $model */ -$class = $generator->modelClass; -$model = new $class; +$model = new $generator->modelClass; $safeAttributes = $model->safeAttributes(); if (empty($safeAttributes)) { $safeAttributes = $model->getTableSchema()->columnNames; @@ -34,7 +33,7 @@ use yii\widgets\ActiveForm; $form = ActiveForm::begin(); ?> generateActiveField($model, $attribute) . " ?>\n\n"; + echo "\t\tgenerateActiveField($attribute) . " ?>\n\n"; } ?>
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', array('class' => 'btn btn-primary')); ?> diff --git a/framework/yii/gii/generators/crud/templates/views/_search.php b/framework/yii/gii/generators/crud/templates/views/_search.php index a9679f1..a649589 100644 --- a/framework/yii/gii/generators/crud/templates/views/_search.php +++ b/framework/yii/gii/generators/crud/templates/views/_search.php @@ -1,38 +1,45 @@ - -/* @var $this getControllerClass(); ?> */ -/* @var $model getModelClass(); ?> */ -/* @var $form CActiveForm */ + +use yii\helpers\Html; +use yii\widgets\ActiveForm; + +/** + * @var yii\base\View $this + * @var searchModelClass, '\\'); ?> $model + * @var yii\widgets\ActiveForm $form + */ ?> -
+ \ No newline at end of file +
diff --git a/framework/yii/gii/generators/crud/templates/views/create.php b/framework/yii/gii/generators/crud/templates/views/create.php index 48a2318..669b99a 100644 --- a/framework/yii/gii/generators/crud/templates/views/create.php +++ b/framework/yii/gii/generators/crud/templates/views/create.php @@ -19,6 +19,8 @@ use yii\helpers\Html; */ $this->title = 'Create modelClass)); ?>'; +$this->params['breadcrumbs'][] = array('label' => 'modelClass))); ?>', 'url' => array('index')); +$this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/framework/yii/gii/generators/crud/templates/views/index.php b/framework/yii/gii/generators/crud/templates/views/index.php index fbac7c3..8efa53a 100644 --- a/framework/yii/gii/generators/crud/templates/views/index.php +++ b/framework/yii/gii/generators/crud/templates/views/index.php @@ -8,19 +8,7 @@ use yii\helpers\StringHelper; * @var yii\gii\generators\crud\Generator $generator */ -/** @var \yii\db\ActiveRecord $model */ -$class = $generator->modelClass; -$pks = $class::primaryKey(); -if (count($pks) === 1) { - $viewUrl = "array('view', 'id' => \$model->{$pks[0]})"; -} else { - $params = array(); - foreach ($pks as $pk) { - $params[] = "'$pk' => \$model->$pk"; - } - $viewUrl = "array('view', " . implode(', ', $params) . ')'; -} - +$urlParams = $generator->generateUrlParams(); $nameAttribute = $generator->getNameAttribute(); echo "indexWidgetType === 'grid' ? 'yii\grid\GridView' : 'y /** * @var yii\base\View $this * @var yii\data\ActiveDataProvider $dataProvider + * @var searchModelClass, '\\'); ?> $searchModel */ $this->title = 'modelClass))); ?>'; +$this->params['breadcrumbs'][] = $this->title; ?>

echo Html::encode($this->title); ?>

-indexWidgetType === 'grid'): ?> + echo $this->render('_search', array('model' => $searchModel)); ?> +
+ +
+ echo Html::a('Create modelClass); ?>', array('create'), array('class' => 'btn btn-danger')); ?> +
+ +indexWidgetType === 'grid'): ?> + echo GridView::widget(array( + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => array( +getTableSchema()->columns as $column) { + $format = $generator->generateColumnFormat($column); + if (++$count < 6) { + echo "\t\t\t'" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; + } else { + echo "\t\t\t// '" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; + } +} +?> + ), + )); ?> - echo ListView::widget(array( + echo ListView::widget(array( 'dataProvider' => $dataProvider, + 'itemOptions' => array( + 'class' => 'item', + ), 'itemView' => function ($model, $key, $index, $widget) { - return Html::a(Html::encode($model->), ); + return Html::a(Html::encode($model->), array('view', ); }, )); ?> diff --git a/framework/yii/gii/generators/crud/templates/views/update.php b/framework/yii/gii/generators/crud/templates/views/update.php index bacc1ec..cb892c2 100644 --- a/framework/yii/gii/generators/crud/templates/views/update.php +++ b/framework/yii/gii/generators/crud/templates/views/update.php @@ -8,6 +8,8 @@ use yii\helpers\StringHelper; * @var yii\gii\generators\crud\Generator $generator */ +$urlParams = $generator->generateUrlParams(); + echo " @@ -19,6 +21,9 @@ use yii\helpers\Html; */ $this->title = 'Update modelClass)); ?>: ' . $model->getNameAttribute(); ?>; +$this->params['breadcrumbs'][] = array('label' => 'modelClass))); ?>', 'url' => array('index')); +$this->params['breadcrumbs'][] = array('label' => $model->getNameAttribute(); ?>, 'url' => array('view', )); +$this->params['breadcrumbs'][] = 'Update'; ?>
diff --git a/framework/yii/gii/generators/crud/templates/views/view.php b/framework/yii/gii/generators/crud/templates/views/view.php index 214f10b..d08ec23 100644 --- a/framework/yii/gii/generators/crud/templates/views/view.php +++ b/framework/yii/gii/generators/crud/templates/views/view.php @@ -8,9 +8,7 @@ use yii\helpers\StringHelper; * @var yii\gii\generators\crud\Generator $generator */ -/** @var \yii\db\ActiveRecord $model */ -$class = $generator->modelClass; -$model = new $class; +$urlParams = $generator->generateUrlParams(); echo " @@ -24,16 +22,23 @@ use yii\widgets\DetailView; */ $this->title = $model->getNameAttribute(); ?>; +$this->params['breadcrumbs'][] = array('label' => 'modelClass))); ?>', 'url' => array('index')); +$this->params['breadcrumbs'][] = $this->title; ?>

echo Html::encode($this->title); ?>

+
+ echo Html::a('Update', array('update', ), array('class' => 'btn btn-danger')); ?> + echo Html::a('Delete', array('delete', ), array('class' => 'btn btn-danger')); ?> +
+ echo DetailView::widget(array( 'model' => $model, 'attributes' => array( getTableSchema()->columns as $column) { +foreach ($generator->getTableSchema()->columns as $column) { $format = $generator->generateColumnFormat($column); echo "\t\t\t'" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; } diff --git a/framework/yii/gii/views/default/view.php b/framework/yii/gii/views/default/view.php index bf05e84..9754918 100644 --- a/framework/yii/gii/views/default/view.php +++ b/framework/yii/gii/views/default/view.php @@ -40,7 +40,7 @@ foreach ($generator->templates as $name => $path) { 'form' => $form, )); ?> field($generator, 'template')->sticky() - ->label(array('label' => 'Code Template')) + ->label('Code Template') ->dropDownList($templates)->hint(' Please select which set of the templates should be used to generated the code. '); ?>