@@ -96,6 +96,7 @@ By default there are the following generators available:
...
@@ -96,6 +96,7 @@ By default there are the following generators available:
-**Form Generator** - This generator generates a view script file that displays a form to collect input for the
-**Form Generator** - This generator generates a view script file that displays a form to collect input for the
specified model class.
specified model class.
-**Module Generator** - This generator helps you to generate the skeleton code needed by a Yii module.
-**Module Generator** - This generator helps you to generate the skeleton code needed by a Yii module.
-**Extension Generator** - This generator helps you to generate the files needed by a Yii extension.
After choosing a generator by clicking on the "Start" button you will see a form that allows you to configure the
After choosing a generator by clicking on the "Start" button you will see a form that allows you to configure the
parameters of the generator. Fill out the form according to your needs and press the "Preview" button to get a
parameters of the generator. Fill out the form according to your needs and press the "Preview" button to get a
...
@@ -127,14 +128,97 @@ adjust directory permissions so that your webserver is able to write to the dire
...
@@ -127,14 +128,97 @@ adjust directory permissions so that your webserver is able to write to the dire
Creating your own templates
Creating your own templates
---------------------------
---------------------------
Every generator has a form field that lets you choose a template to use for code generation.
Every generator has a form field `Code Template`that lets you choose a template to use for code generation.
By default gii only provides one template but you can create your own templates that are adjusted to your needs.
By default gii only provides one template `default`but you can create your own templates that are adjusted to your needs.
TBD
If you open a folder `@app\vendor\yiisoft\yii2-gii\generators`, you'll see six folders of generators.
```
+ controller
- crud
+ default
+ extension
+ form
+ model
+ module
```
This is name generator. If you open any of these folders, you can see the folder `default`. This folder is name of the template.
Copy folder `@app\vendor\yiisoft\yii2-gii\generators\crud\default` to another location, for example `@app\myTemplates\crud\`. Now open this folder and modify any template to fit your desires, for example, add `errorSummary` in `views\_form.php`:
'myCrud'=>'@app\myTemplates\crud\default', //name tempate => path to template
]
]
],
];
}
```
Open the CRUD generator and you will see that in the field `Code Template` of form appeared own template .
Creating your own generators
Creating your own generators
----------------------------
----------------------------
TBD
Open the folder of any generator and you will see two files `form.php` and `Generator.php`. One is the form, the second is the class generator. For create your own generator, you need to create or override these classes in any folder. Again as in the previous paragraph customize configuration: