- Table of Contents
7. Gii Support - 6.10. Soft Documents Models
« Previous - 8. Special Topics
Next »
7. Gii Support
Author | Dariusz Górecki |
---|
Model generation
Since version 1.3.4 you can generate mongo document models based on existing SQL tables, just enable gii generators
provided within package (see below) and use MongoModel
generator.
CRUD Generation
Now you can generate CRUD for yours MongoDB Documents! just you have to add generator path to yours Gii config
By default generated models will use mongo
_id
field as a primary key (using MongoId class) this generator will use different field as a primary key, if you will overrideprimaryKey()
method to return something different than '_id'. Note that generator cannot handle with multifield primary key,
// in yours main.php config file: 'modules'=>array( // ... 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'yours_password_to_gii', // add additional generator path 'generatorPaths'=>array( 'ext.YiiMongoDbSuite.gii' ), ), // ... ), // Now login to Gii and start using Mongocrud generator !
Forms generation
- This is a good news, Gii can generate the worst part of developer job, forms for mongo records ;]
- When generating a form from mongo record, comment out embedded docs array, or you'll see error about array/object creation
- For embedded docs just generate forms in separed way for each one
- 7. Gii Support
Table of Contents - « Previous
6.10. Soft Documents Models - Next »
8. Special Topics