I am trying to use my own set of templates to generate cruds and models with giiant by Tobias Munk and folowing: https://github.com/schmunk42/yii2-giiant/blob/master/docs/32-customizations.md
but I cant make it work.
First I copy the /yii2-giiant/src/generators directory into my app and did some changes.
Then I changed the config as follow:
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1'],
'generators' => [
// generator name
'giiant-model' => [
//generator class
'class' => 'schmunk42\giiant\generators\model\Generator',
//setting for out templates
'templates' => [
// template name => path to template
'oemodel' =>
'@app/oetemplates/model/default',
]
]
],
];
but when I run the giiant form from the admin is not picking up my code.
I can also see in the form a select box that shows the default directory with the templates. but not sure how to add mine there.
Any ideas welcome...
The way I was following schmunk42 documentation was fine and not sure why it wasn't working. Maybe I didn't test correctly or I didn't added the configuration in the right place.
But if you are using schmunk42/yii2-giiant module, and you want to use your own template to generate code without touching the module.
The following configuration should bring you your own model in the select box
In my case, as i said, I just copied the /yii2-giiant/src/generators directory into my app (in my case) inside oetemplates:
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => $allowedIPs,
];
$giiant = require __DIR__.'/giiant.php';
$config = \yii\helpers\ArrayHelper::merge($config, $giiant);
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1'],
'generators' => [
// generator name
'giiant-model' => [
//generator class
'class' => 'schmunk42\giiant\generators\model\Generator',
//setting for out templates
'templates' => [
// template name => path to template
'oemodel' =>
'@app/oetemplates/model/default',
]
]
],
];
Then when I go to the backend i can see in the Giiant Model my template:
And it works just fine.