diff --git a/framework/yii/gii/generators/crud/Generator.php b/framework/yii/gii/generators/crud/Generator.php index ae59102..671dfbd 100644 --- a/framework/yii/gii/generators/crud/Generator.php +++ b/framework/yii/gii/generators/crud/Generator.php @@ -190,9 +190,9 @@ class Generator extends \yii\gii\Generator } $column = $tableSchema->columns[$attribute]; if ($column->phpType === 'boolean') { - return "\$form->field(\$model, '$attribute')->checkbox();"; + return "\$form->field(\$model, '$attribute')->checkbox()"; } elseif ($column->type === 'text') { - return "\$form->field(\$model, '$attribute')->textarea(['rows' => 6]);"; + return "\$form->field(\$model, '$attribute')->textarea(['rows' => 6])"; } else { if (preg_match('/^(password|pass|passwd|passcode)$/i', $column->name)) { $input = 'passwordInput'; @@ -200,9 +200,9 @@ class Generator extends \yii\gii\Generator $input = 'textInput'; } if ($column->phpType !== 'string' || $column->size === null) { - return "\$form->field(\$model, '$attribute')->$input();"; + return "\$form->field(\$model, '$attribute')->$input()"; } else { - return "\$form->field(\$model, '$attribute')->$input(['maxlength' => $column->size]);"; + return "\$form->field(\$model, '$attribute')->$input(['maxlength' => $column->size])"; } } } @@ -216,9 +216,9 @@ class Generator extends \yii\gii\Generator $tableSchema = $this->getTableSchema(); $column = $tableSchema->columns[$attribute]; if ($column->phpType === 'boolean') { - return "\$form->field(\$model, '$attribute')->checkbox();"; + return "\$form->field(\$model, '$attribute')->checkbox()"; } else { - return "\$form->field(\$model, '$attribute');"; + return "\$form->field(\$model, '$attribute')"; } } diff --git a/framework/yii/gii/generators/crud/templates/views/_form.php b/framework/yii/gii/generators/crud/templates/views/_form.php index 9f0626f..59ed780 100644 --- a/framework/yii/gii/generators/crud/templates/views/_form.php +++ b/framework/yii/gii/generators/crud/templates/views/_form.php @@ -30,15 +30,15 @@ use yii\widgets\ActiveForm;
- $form = ActiveForm::begin(); ?> + $form = ActiveForm::begin(); ?> generateActiveField($attribute) . " ?>\n\n"; + echo "\t\tgenerateActiveField($attribute) . " ?>\n\n"; } ?>
- echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> + Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
- ActiveForm::end(); ?> + ActiveForm::end(); ?>
diff --git a/framework/yii/gii/generators/crud/templates/views/_search.php b/framework/yii/gii/generators/crud/templates/views/_search.php index be92360..ff9a0dd 100644 --- a/framework/yii/gii/generators/crud/templates/views/_search.php +++ b/framework/yii/gii/generators/crud/templates/views/_search.php @@ -23,7 +23,7 @@ use yii\widgets\ActiveForm; diff --git a/framework/yii/gii/generators/crud/templates/views/create.php b/framework/yii/gii/generators/crud/templates/views/create.php index 2cb4b91..02c30bf 100644 --- a/framework/yii/gii/generators/crud/templates/views/create.php +++ b/framework/yii/gii/generators/crud/templates/views/create.php @@ -24,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

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

+

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

- echo $this->render('_form', [ + echo $this->render('_form', [ 'model' => $model, ]); ?> diff --git a/framework/yii/gii/generators/crud/templates/views/index.php b/framework/yii/gii/generators/crud/templates/views/index.php index fe2e266..d3cebcc 100644 --- a/framework/yii/gii/generators/crud/templates/views/index.php +++ b/framework/yii/gii/generators/crud/templates/views/index.php @@ -15,7 +15,7 @@ echo " use yii\helpers\Html; -use indexWidgetType === 'grid' ? 'yii\grid\GridView' : 'yii\widgets\ListView' ?>; +use indexWidgetType === 'grid' ? "yii\grid\GridView" : "yii\widgets\ListView" ?>; /** * @var yii\base\View $this @@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

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

+

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

- indexWidgetType === 'grid' ? ' //' : '') ?> echo $this->render('_search', ['model' => $searchModel]); ?> + indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?>

- echo Html::a('Create modelClass) ?>', ['create'], ['class' => 'btn btn-success']); ?> + Html::a('Create modelClass) ?>', ['create'], ['class' => 'btn btn-success']) ?>

indexWidgetType === 'grid'): ?> - echo GridView::widget([ + echo GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ @@ -48,9 +48,9 @@ $count = 0; foreach ($generator->getTableSchema()->columns as $column) { $format = $generator->generateColumnFormat($column); if (++$count < 6) { - echo "\t\t\t'" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; + echo "\t\t\t'" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; } else { - echo "\t\t\t// '" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; + echo "\t\t\t// '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; } } ?> @@ -59,7 +59,7 @@ foreach ($generator->getTableSchema()->columns as $column) { ], ]); ?> - echo ListView::widget([ + echo ListView::widget([ 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) { diff --git a/framework/yii/gii/generators/crud/templates/views/update.php b/framework/yii/gii/generators/crud/templates/views/update.php index 32bab23..903a880 100644 --- a/framework/yii/gii/generators/crud/templates/views/update.php +++ b/framework/yii/gii/generators/crud/templates/views/update.php @@ -27,9 +27,9 @@ $this->params['breadcrumbs'][] = 'Update'; ?>
-

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

+

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

- echo $this->render('_form', [ + echo $this->render('_form', [ 'model' => $model, ]); ?> diff --git a/framework/yii/gii/generators/crud/templates/views/view.php b/framework/yii/gii/generators/crud/templates/views/view.php index 2832507..a15a7b6 100644 --- a/framework/yii/gii/generators/crud/templates/views/view.php +++ b/framework/yii/gii/generators/crud/templates/views/view.php @@ -27,24 +27,24 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

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

+

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

- echo Html::a('Update', ['update', ], ['class' => 'btn btn-primary']); ?> - echo Html::a('Delete', ['delete', ], [ + Html::a('Update', ['update', ], ['class' => 'btn btn-primary']) ?> + echo Html::a('Delete', ['delete', ], [ 'class' => 'btn btn-danger', 'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'), 'data-method' => 'post', ]); ?>

- echo DetailView::widget([ + echo DetailView::widget([ 'model' => $model, 'attributes' => [ getTableSchema()->columns as $column) { $format = $generator->generateColumnFormat($column); - echo "\t\t\t'" . $column->name . ($format === 'text' ? '' : ':' . $format) . "',\n"; + echo "\t\t\t'" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; } ?> ],