Commit 0293570a by Qiang Xue

Merge pull request #1038 from lucianobaraglia/master

GII - short echo syntax
parents 380bb5cc bb1f8858
......@@ -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')";
}
}
......
......@@ -30,15 +30,15 @@ use yii\widgets\ActiveForm;
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-form">
<?= '<?php' ?> $form = ActiveForm::begin(); ?>
<?= "<?php " ?>$form = ActiveForm::begin(); ?>
<?php foreach ($safeAttributes as $attribute) {
echo "\t\t<?=" . $generator->generateActiveField($attribute) . " ?>\n\n";
echo "\t\t<?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
} ?>
<div class="form-group">
<?= '<?php' ?> 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']) ?>
</div>
<?= '<?php' ?> ActiveForm::end(); ?>
<?= "<?php " ?>ActiveForm::end(); ?>
</div>
......@@ -23,7 +23,7 @@ use yii\widgets\ActiveForm;
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-search">
<?= '<?php' ?> $form = ActiveForm::begin([
<?= "<?php " ?>$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
......@@ -32,17 +32,17 @@ use yii\widgets\ActiveForm;
$count = 0;
foreach ($generator->getTableSchema()->getColumnNames() as $attribute) {
if (++$count < 6) {
echo "\t\t<?=" . $generator->generateActiveSearchField($attribute) . " ?>\n";
echo "\t\t<?= " . $generator->generateActiveSearchField($attribute) . " ?>\n\n";
} else {
echo "\t\t<?php // echo " . $generator->generateActiveSearchField($attribute) . " ?>\n";
echo "\t\t<?= // " . $generator->generateActiveSearchField($attribute) . " ?>\n\n";
}
}
?>
<div class="form-group">
<?= '<?php' ?> echo Html::submitButton('Search', ['class' => 'btn btn-primary']); ?>
<?= '<?php' ?> echo Html::resetButton('Reset', ['class' => 'btn btn-default']); ?>
<?= "<?= " ?>Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= "<?= " ?>Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?= '<?php' ?> ActiveForm::end(); ?>
<?= "<?php " ?>ActiveForm::end(); ?>
</div>
......@@ -24,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-create">
<h1><?= "<?php" ?> echo Html::encode($this->title); ?></h1>
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
<?= "<?php" ?> echo $this->render('_form', [
<?= "<?php " ?>echo $this->render('_form', [
'model' => $model,
]); ?>
......
......@@ -15,7 +15,7 @@ echo "<?php\n";
?>
use yii\helpers\Html;
use <?= $generator->indexWidgetType === 'grid' ? 'yii\grid\GridView' : 'yii\widgets\ListView' ?>;
use <?= $generator->indexWidgetType === 'grid' ? "yii\grid\GridView" : "yii\widgets\ListView" ?>;
/**
* @var yii\base\View $this
......@@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-index">
<h1><?= "<?php" ?> echo Html::encode($this->title); ?></h1>
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
<?= '<?php' . ($generator->indexWidgetType === 'grid' ? ' //' : '') ?> echo $this->render('_search', ['model' => $searchModel]); ?>
<?= "<?php " . ($generator->indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= '<?php' ?> echo Html::a('Create <?= StringHelper::basename($generator->modelClass) ?>', ['create'], ['class' => 'btn btn-success']); ?>
<?= "<?= " ?>Html::a('Create <?= StringHelper::basename($generator->modelClass) ?>', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?php if ($generator->indexWidgetType === 'grid'): ?>
<?= "<?php" ?> echo GridView::widget([
<?= "<?php " ?>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) {
],
]); ?>
<?php else: ?>
<?= "<?php" ?> echo ListView::widget([
<?= "<?php " ?>echo ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
'itemView' => function ($model, $key, $index, $widget) {
......
......@@ -27,9 +27,9 @@ $this->params['breadcrumbs'][] = 'Update';
?>
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-update">
<h1><?= "<?php" ?> echo Html::encode($this->title); ?></h1>
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
<?= "<?php" ?> echo $this->render('_form', [
<?= "<?php " ?>echo $this->render('_form', [
'model' => $model,
]); ?>
......
......@@ -27,24 +27,24 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-view">
<h1><?= "<?php" ?> echo Html::encode($this->title); ?></h1>
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
<p>
<?= '<?php' ?> echo Html::a('Update', ['update', <?= $urlParams ?>], ['class' => 'btn btn-primary']); ?>
<?= '<?php' ?> echo Html::a('Delete', ['delete', <?= $urlParams ?>], [
<?= "<?= " ?>Html::a('Update', ['update', <?= $urlParams ?>], ['class' => 'btn btn-primary']) ?>
<?= "<?php " ?>echo Html::a('Delete', ['delete', <?= $urlParams ?>], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'data-method' => 'post',
]); ?>
</p>
<?= '<?php' ?> echo DetailView::widget([
<?= "<?php " ?>echo DetailView::widget([
'model' => $model,
'attributes' => [
<?php
foreach ($generator->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";
}
?>
],
......
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