Generate Relational (hasMany, hasOne, belongsTo, & nested) Models & CRUD.

Installs: 138 977

Dependents: 11

Suggesters: 0

Security: 0

Stars: 201

Watchers: 36

Forks: 100

Open Issues: 43


v1.0.0 2016-08-20 03:42 UTC

This package is not auto-updated.

Last update: 2024-05-11 15:42:10 UTC


Yii2 Gii (generator) with Relation

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads Join the chat at Yii2


Support via Gratipay

Endorse me on LinkedIn


The preferred way to install this extension is through composer.

Either run

$ composer require mootensai/yii2-enhanced-gii:dev-master
$ composer require kartik-v/yii2-mpdf:dev-master # if you want to use pdf exporter 
$ composer require kartik-v/yii2-tree-manager:dev-master # if you want to use tree/nested relation table

or add

"mootensai/yii2-enhanced-gii": "dev-master",
"kartik-v/yii2-mpdf": "dev-master",
"kartik-v/yii2-tree-manager": "dev-master"

add "kartik-v/yii2-mpdf": "dev-master", if you want to use pdf exporter

add "kartik-v/yii2-tree-manager": "dev-master", if you want to use tree/nested relation table

to the require section of your composer.json file.

I separate the mpdf & tree-manager because the package is big & not everyone will use it.

Then you must add this code at your config\main.php.

'modules' => [
... //your another module
      'gridview' => [
          'class' => '\kartik\grid\Module',
          // see settings on
      'datecontrol' => [
          'class' => '\kartik\datecontrol\Module',
          // see settings on
      // If you use tree table
      'treemanager' =>  [
          'class' => '\kartik\tree\Module',
          // see settings on
... // your another module

See gridview settings on

See datecontrol settings on

See treemanager settings on (If you use tree/nested relation table)

Usage :

Go to your gii tools, and notice the new IO Generator for models & CRUD


Model :

  1. Generate optimistic lock
  2. Generate Timestamp Behaviors
  3. Generate Blameable Behavior
  4. Generate UUID Behavior
  5. Generate Soft Delete Behavior (NEW! Todo : Generate data filtering for relation data, e.g. not show deleted children of hasMany )


  1. Generate all CRUD with wildcard (*) of table
  2. Generate related input output
  3. Specify your name/label attribute for foreign keys
  4. Set your column to hidden
  5. Specify your skipped columns
  6. Specify your skipped relations
  7. Set pluralize or not
  8. PDF Printable view
  9. Expandable / collapsible row at index grid view for related data

Migration Generator :

  1. Generate migration from your database structure (based on :
  2. Option to generate with safeUp() and safeDown()

To Do

  1. One-page-CRUD template
  2. Implement generator for Soft Delete Behavior (

I'm open for any improvement


Model Generator

enhanced gii - model

CRUD Generator

enhanced gii - crud


Grid View

enhanced gii - index grid

List View

enhanced gii - index list


enhanced gii - view


enhanced gii - create

enhanced gii - update

Nested / Tree

enhanced gii - nested

Migration Generator

migration form

Thanks To

  1. Jiwanndaru ( for creating the tradition
  2. kartik-v ( for most of widgets
  3. schmunk42 ( for bootstrap & model base & extension
  4. mdmunir ( for JsBlock & Migration Generator (from