Gii CRUD and automatic field types


Is there any extension or something that detects the field type (with comments maybe?) and generate the appropriate form input, like file uploads, checkboxes, radio… even selects for related tables?


Hey Vicente

There’s no extension, as far as I know, to do such thing

I did something myself for personal use, if you are interested

Its not as complex as you may want, but it handles most cases


There are gii templates like (use the svn version, had a litte problems with the release) that will generate crud and models for you.

the nice thing is relation will be used (with a relation extension) and boolean will be used with checkboxes.

Its not the exact thing that you want but its better than nothing ;)

Gustavo, I’ll sure want to take a look at your code! :)

I’m testing this right now, tks!

here, there’s also a bit more, its what I use for personal use, so it includes some dependencies, like my controller and other stuff

to use it just put the folder "mpgii" under "/protected/extensions/" and set up like this:




            	'generatorPaths' =>array('ext.mpgii'),


and the rest of the files under /protected/components

also in the config file before anything



for model generator:[/b]

it creates the timestamp behavior for fields based on type and name

it also comes with an extension created by me to handle multiple database connections

for form and crud generators

what it handles:

  • password fields based on column’s name
  • select fields based on related tables
  • checkbox if column type is integer(1) or boolean
  • textarea field if column type is text or char/varchar >255 length
  • handles enum fields, making it select boxes
  • file fields based on columns name

for the module generator

it includes support for creation of nested modules, like explained in this post by me

like apps/blog will create a blog module under apps module

tested with MySql and Yii 1.1.6

take a look and tell me what you think

Cheers / Abraço

EDIT: Delete the file because it has too much dependencies and will only cause you problems

I’ll consider to add as extension later on