Commit 7a376175 by Luciano Baraglia

Enable I18N for GII form generator

parent 3eb90c54
......@@ -70,6 +70,8 @@ class Generator extends \yii\gii\Generator
[['viewPath'], 'match', 'pattern' => '/^@?\w+[\\-\\/\w]*$/', 'message' => 'Only word characters, dashes, slashes and @ are allowed.'],
[['viewPath'], 'validateViewPath'],
[['scenarioName'], 'match', 'pattern' => '/^[\w\\-]+$/', 'message' => 'Only word characters and dashes are allowed.'],
[['enableI18N'], 'boolean'],
[['messageCategory'], 'validateMessageCategory', 'skipOnEmpty' => false],
]);
}
......@@ -78,12 +80,12 @@ class Generator extends \yii\gii\Generator
*/
public function attributeLabels()
{
return [
return array_merge(parent::attributeLabels(), [
'modelClass' => 'Model Class',
'viewName' => 'View Name',
'viewPath' => 'View Path',
'scenarioName' => 'Scenario',
];
]);
}
/**
......@@ -99,7 +101,7 @@ class Generator extends \yii\gii\Generator
*/
public function stickyAttributes()
{
return ['viewPath', 'scenarioName'];
return array_merge(parent::stickyAttributes(), ['viewPath', 'scenarioName']);
}
/**
......@@ -107,12 +109,12 @@ class Generator extends \yii\gii\Generator
*/
public function hints()
{
return [
return array_merge(parent::hints(), [
'modelClass' => 'This is the model class for collecting the form input. You should provide a fully qualified class name, e.g., <code>app\models\Post</code>.',
'viewName' => 'This is the view name with respect to the view path. For example, <code>site/index</code> would generate a <code>site/index.php</code> view file under the view path.',
'viewPath' => 'This is the root view path to keep the generated view files. You may provide either a directory or a path alias, e.g., <code>@app/views</code>.',
'scenarioName' => 'This is the scenario to be used by the model when collecting the form input. If empty, the default scenario will be used.',
];
]);
}
/**
......
......@@ -28,7 +28,7 @@ use yii\widgets\ActiveForm;
<?php endforeach; ?>
<div class="form-group">
<?= "<?= " ?>Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
<?= "<?= " ?>Html::submitButton(<?= $generator->generateString('Submit') ?>, ['class' => 'btn btn-primary']) ?>
</div>
<?= "<?php " ?>ActiveForm::end(); ?>
......
......@@ -8,3 +8,5 @@ echo $form->field($generator, 'viewName');
echo $form->field($generator, 'modelClass');
echo $form->field($generator, 'scenarioName');
echo $form->field($generator, 'viewPath');
echo $form->field($generator, 'enableI18N')->checkbox();
echo $form->field($generator, 'messageCategory');
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