Gii Template Collection with code templates for models and CRUDs
Latest commit bccead8 Jan 13, 2016 @schmunk42 added Yii 1.1 info
Failed to load latest commit information.
components Merge branch 'develop' of … Apr 24, 2014
fullCrud For create title optimized and button SAVE permisions fixed Nov 1, 2015
fullModel To base model added delete, where included related teble record delete Oct 28, 2015
fullModule To relation item grids added alert and warning mesaging Sep 15, 2014
sreenshots Added screenshots Jun 1, 2014
.gitignore add .idea to ignore Apr 16, 2014
changelog.txt Added columnname that is used by the OwnerBehavior May 22, 2012
composer.json Update composer.json Jul 28, 2014


Code templates for Yii 1.1 Framework

Fork on github

The gii-template-collection (gtc) contains templates for the Yii Framework Gii module.

For a Yii 2 port of this project, please visit giiant.


  • relation handling
  • YiiBooster integration
  • giic prove
  • customize inputs with code-providers, detect input-type by model and column
    • date and time pickers
    • checkboxes
    • relation widgets
    • editable grid columns
    • partial views
    • enum fields
  • multi languages





Model Classes in two files BaseModel, Model


Standard Model Class Model


Note: Relation widgets moved to


Bootstrap UI with relations


Bootstrap UI with relations and grids



FullCrud Slim Editable List

FullCrud Slim Editable List


Original gtc CRUDs


  • PHP 5.3 and short_open_tags = On



Get it via composer:

composer.phar require phundament/gii-template-collection


Download latest release To use it, simply extract the content of the archive into your application extensions/ directory.


  1. Configure the templates in the generatorPaths section of the gii configuration inside your application configuration:

        'password'=>'<your gii password>',

    After that, the new generators of gtc should be available in your Gii index page.

  2. The last step is to add some gtc components to your import path so they can be found by the application:

    // autoloading model and component classes
        // relation widget and save behavior
  3. For Debugging Information plz add the log under yours config console

    'components' => array(
        'log'      => array(
            'class'  => 'CLogRouter',
            'routes' => array(
                // file logging
                    'class'   => 'CFileLogRoute',
                    'logFile' => 'console.log',
                    'levels'  => 'error, warning, info, trace',
                    'enabled' => true,


Full Module

  • open Gii
  • select FullModule
  • enter Module ID
  • click preview
  • click generate

Full Model

  • open Gii
  • select FullModel
  • enter model class
  • click preview
  • click generate


Note: Generated templates require clevertech/yiibooster >=1.1.1 Note: slim_editable require vitalets/x-editable-yii dev

  • open Gii
  • select FullCrud
  • enter model class
  • click preview
  • click generate


Controller actions and UI buttons follow these checkAccess rules:

  • Controller.*
  • Controller.View
  • Controller.Delete
  • ...

From 0.13.0 on the a Controller.SimpleUi item was added by default, which hides UI elements, when this item is assigned to the current user.

Note: An admin (superuser) always sees the full UI.

Template slim

Requirements:, schmunk42/yii-relation

Template slim editable


  • schmunk42/yii-relation,
  • x-editable-yii
    • php composer.phar require vitalets/x-editable-yii dev-master
    • in config add to aliases vendor.vitalets.x-editable-yii

Template hybrid

An enhanced hybrid between the default/slim templates and the bootstrap crud generator.

Requires x-editable-yii dev and echosen.


Code Providers

The FullCrudCode is able to access providers from a provider-queue to render fields, labels, etc. You can call a provider from your template with, eg.:

$this->provider()->generateColumn($this->modelClass, $column)

FullCrudCode will walk the provider queue until it finds a provider which has the requested method AND which returns not null. This is on of the major differences compared to a behavior.


Render a populated dropdown, if the model contains and optsColumnName() method.

public function generateActiveField($model, $column)
    $func = "opts".str_replace("_","",$column->name);
    if (method_exists($model, $func)) {
        return "echo \$form->dropDownList(\$model,'{$column->name}',{$model}::{$func}());";

Coding Standards

GTC is using <?=""?> Bobsled Coding Style.

  • Write PHP code to be generated wrapped in short-open-echo tags and double quotes
  • Use bobsled only for generating PHP code (in the gtc templates), DO NOT use short open tags in outputted code (yet)
  • Use brackets {} to insert variables for generated code
  • Use a provider to generate fields, labels, relations and columns.
  • Follow guidelines for-good schema design from the Yii Wiki
  • Use a UNIQUE index over both of your foreign keys in your MANY_MANY tables



Known Problems and Limitations

  • gtc does not support composite primary keys




This project has been originally created by thyseus back in 2010.

To quote from the original project page:

Please enjoy this extension and let us collect as many Templates as possible for other people to enjoy. (haml, smarty, dwoo, twig, ...)

In 2011 schmunk create the currently active fork of the project from revision 186 of the Google Code repository.

While there has been much, much, much, … code added over the time. At the end of July 2013 gtc was completely refurbished.


Active maintainers are written in bold.


Of course, any templates are appreciated and just leave a comment or mail:, or