0.0.1
0.0.1.0Yii2 gii for chinese
Apache-2.0
The Requires
by funson86
extension yii2 blog
Yii2 gii for chinese
主要针对中文和项目的优化, (*1)
1.在生成的视图index.php替换'status', (*2)
[ 'attribute' => 'status', 'format' => 'html', 'value' => function ($model) { if ($model->status === $model::STATUS_ACTIVE) { $class = 'label-success'; } elseif ($model->status === $model::STATUS_INACTIVE) { $class = 'label-warning'; } else { $class = 'label-danger'; } return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>'; }, 'filter' => Html::activeDropDownList( $searchModel, 'status', $arrayStatus, ['class' => 'form-control', 'prompt' => Yii::t('app', 'PROMPT_STATUS')] ) ],
2.在生成的视图_form.php替换如下代码, (*3)
<?= $form->field($model, 'status')->textInput() ?> <?= $form->field($model, 'status')->dropDownList(\common\models\User::getArrayStatus()) ?>
3.在生成的视图view.php替换'status', (*4)
[ 'attribute' => 'status', 'value' => $model->statusLabel, ], 'created_at:datetime', 'updated_at:datetime',
The preferred way to install this extension is through composer., (*5)
Either run, (*6)
php composer.phar require funson86/yii2-gii "dev-master"
or add, (*7)
"funson86/yii2-gii": "dev-master"
to the require section of your composer.json
file., (*8)
Once the extension is installed, simply use it in your code by :, (*9)
在main-local.php中配置:, (*10)
if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = 'yii\debug\Module'; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => [ //here 'crud' => [ //name generator 'class' => 'yii\gii\generators\crud\Generator', //class generator 'templates' => [ //setting for out templates 'funson86' => '@vendor/funson86/yii2-gii/crud/default', //name template => path to template 'funson86-status' => '@vendor/funson86/yii2-gii/crud/status', //name template => path to template ] ], 'model' => [ //name generator 'class' => 'yii\gii\generators\model\Generator', //class generator 'templates' => [ //setting for out templates 'funson86' => '@vendor/funson86/yii2-gii/model/default', //name template => path to template 'funson86-status' => '@vendor/funson86/yii2-gii/model/status', //name template => path to template ] ], ], ]; }
在gii新建模板时会多出一个选项。, (*11)
如果要统一输出显示的日期时间格式,修改config/main.php, (*12)
'formatter' => [ 'dateFormat' => 'yyyy-MM-dd', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss', 'decimalSeparator' => ',', 'thousandSeparator' => ' ', 'currencyCode' => 'EUR', ],
Yii2 gii for chinese
Apache-2.0
extension yii2 blog