Yii v2 snippet guide

Comparing #170 with #171

Revision #171 was created by rackycz rackycz on Mar 19, 2020, 9:48:17 PM.

gii

Content

[...]
});
</script>

</html>
```

 
 
**Enhancing Gii**
 
---
 
If you do not like entering long model-paths and controller-paths in CRUD-generator, you can modify text boxes in "\vendor\yiisoft\yii2-gii\src\generators\crud\form.php" and enter default paths and then only manually add the name of the model.
 
 
```php
 
if (!$generator->modelClass) {
 
echo $form->field($generator, 'modelClass')->textInput(['value' => 'app\\models\\']);
 
echo $form->field($generator, 'searchModelClass')->textInput(['value' => 'app\\models\\*Search']);
 
echo $form->field($generator, 'controllerClass')->textInput(['value' => 'app\\controllers\\*Controller']);
 
} else {
 
echo $form->field($generator, 'modelClass');
 
echo $form->field($generator, 'searchModelClass');
 
echo $form->field($generator, 'controllerClass');
 
}
 
```