awegen is an awesome code generator for Yii framework.
awegen borrows goodies from giix and gtc.
What It Does? ¶
- Generates textarea for
text
db type - Generates textarea with markitp editor for
longtext
db type (Uses markitup widget) - Generates checkbox for
boolean
db types - Uses JToggleColumn for
boolean
types in Admin/CGridView (Uses JToggleColumn extension) - Generates fields with Datepicker for
date
db type - Generates fields with Datetimepicker for
time
,datetime
andtimestamp
db type (Uses datetimepicker widget) - Allows easy addition of access control templates in the generator
( Users can add templates intoAweCrud/templates/default/auth
folder and they will be listed in the CRUD generator) - Guesses e-mail fields by field names and adds e-mail validation for forms and mailto links for views
- Guesses image fields by field names and tries to display the image in views
- Guesses url fields by field names and adds url validation for forms and creates links for views
- Guesses password fields by field names, generates password fields for them in forms and hides them from non-admin users in views
- Guesses createtime and updatetime fields and adds proper timestamp behaviour to them
- Uses Activerecord-relation-behavior to handle all kinds of relations
- Creates pulldown menu for one-to-many and one-to-one relations
- Creates checkboxes for fields with many-to-many relations
- Keeps generated code in abstract base model so that regeneration doesn't overwrite user changes
- Guesses identification column for models and uses them in headings and breadcrumbs
(Looks for following fields in order of priority - name, title, slug, any field withname
in its name, first non-numeric field, primary key) - Handles parent-child relationship of items among same model
(Allows an item to be parent/child of any other items from the same table but not itself)
Installation ¶
Download from https://github.com/xtranophilist/awegen/zipball/master
Extract the content of the archive to extensions directory and rename the top level directory from extrancted content to awegen
.
Add the path of awegen to generatorPaths section in gii module configuration in config/main.php
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'password',
'generatorPaths' => array(
'ext.awegen',
),
),
...
),
Add the components required to your imports section
'import' => array(
...
'application.extensions.awegen.components.*',
),
Usage ¶
Browse to /gii, login and select AweModel Generator to create Model and then AweCrud to generate Controller and Views.
Use *
for table name in Model generator to preview all models. Generate all or selectively.
nice so far, but it depends on a user module
Everything works, but the generated code depends on a user management module.
views/-model-/view.php line 23 has a Yii::app()->getModule('user') which is not available for a default yii application.
Thats the only problem i have found so far, its a GREAT extension and combines (and cleans up) most of the features of gtc and giix ! +1 ;)
Fixed dependency on user module
@thyseus
Thank you very much, that has been fixed. The generator now looks if the user module is available.
error
I have an error when trying to use AweCrud Generator:
include(Awecms.php): failed to open stream: No such file or directory
Import Components
@UncleSym
Maybe you forgot to import components.
Awecms.php
happens to be in'application.extensions.awegen.components.*'
. Add it to your imports section inconfig/main.php
as instructed in installation section above.Cloning from the github doesn't get you the dependencies. You have to download from the downloads page or from here.
Return me this erro
When I click in Gii on menu "AweCrud Generator" return me this error:
on AweCMS CRUD Generator
Fields with * are required. Click on the highlighted fields to edit them.
Model Class *
Error
I got the following error while genertaing the AweCRUD
AweCMS CRUD Generator
Fields with * are required. Click on the highlighted fields to edit them.
Model Class *
No Awegen Options In GII
Hi,
I've installed the extension as described, but I'm still not seeing any new options in Gii. Here is an excerpt from my config file:
// autoloading model and component classes 'import'=>array( 'application.models.*', 'application.components.*', 'application.extensions.awegen.components.*', 'ext.giix.giix-components.*', // giix components ), 'modules'=>array( 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'password_here', // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters'=>array('127.0.0.1','::1'), 'generatorPaths' => array( 'ext.awegen', 'ext.giix.giix-core', ), ), 'admin', ),
Thanks for any help!
Updated
awegen has been updated. To prevent the confusion, I've included components in the git repo too. Fix by sam to bulk-generate models from all tables has also been pulled.
Unable to resolve the request "gii/AweModel".
I've installed the extension as described. When I get to the gii page and I click on "AweCrud Generator" or "AweModel Generator"
I get the error Unable to resolve the request "gii/AweModel".
The other normal gii functions work perfectly.
I am using the following config:
Apache/2.2.22 (Win32) PHP/5.3.10 Yii Framework/1.1.10 and a .htaccess file in the root directory:
Following is my config/main.php file:
'import' => array ( 'application.models.*', 'application.components.*', 'application.modules.user.models.*', 'application.modules.user.components.*', 'application.modules.srbac.controllers.SBaseController', 'application.extensions.awegen.components.*', ), 'modules' => array ( // uncomment the following to enable the Gii tool 'gii' => array ( 'class' => 'system.gii.GiiModule', 'password' => 'password', 'generatorPaths' => array ( 'ext.awegen', ), // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters' => array('127.0.0.1', '::1'), ), ... ), // application components 'components' => array ( // uncomment the following to enable URLs in path-format 'urlManager' => array ( 'urlFormat' => 'path', 'showScriptName' => false, 'caseSensitive' => false, 'rules' => array ( '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ), ), ... ),
Thank you in advance.
Bug in class AweCrudCode in function generateGridViewColumn
There's a bug in function generateGridViewColumn(). Relations columns are not generated propertly in /views/[controller]/admin.php.
You need to set variable $relatedModelName. Just add this line in AweCrudCode.php (between line 286 and 287):
~~~
$relatedModelName = get_class($relatedModel);
~~~
Can not create CRUD
I am receiving this error while creating CRUD;
PHP warning
include(self.php) [function.include]: failed to open stream: No such file or directory
Looks like PHP version incompatibility
@anilherath
I am not sure about the problem. My guess is your PHP version is older than 5.3. If your server has multiple versions installed and 5.3 isn't the default one, you can force the server to use PHP v5.3 by adding the following line to your .htaccess file in the root folder of your project.
~~~
AddType application/x-httpd-php53 .php
~~~
Php version
You are correct. My php version is 5.2. Thank you and sorry for the inconvenience.
Text Editor
Hi, how we can implement tinymce text editor with longtext type of columns.
Using text editor other than Markitup
@Mohammad Shahid: Look for the text
$this->widget('EMarkitupWidget'
in generateField() method in AweCrudCode.phpModify that line to use any editor of your choice.
Unable to resolve the request "gii/AweModel".
I had this error and sorted it by turning off seo urls, use plain old index.php?r=gii
Issue
Hi
Using a base for the models is excellent (I can't disagree with what I did in other contexts).
There is an issue with some parts of the generator. Here is one, I got the following line generated for the CRUD where it refers to AweCms::pluralize which does not exist.
echo "<?php echo CHtml::link(Yii::t('app', Awecms::pluralize('Sub-Page', '" . ucfirst($key) . "', count(\$model->{$key}))), array('" . $controller . "'));?>";
Fatal error: Call to undefined method Awecms::getPrimaryKeyColumn()
I received the above error. I then went to \awegen\components\Awecms.php and changed getPrimaryKey to getPrimaryKeyColumn on line 19 seeing that it had been refactored on git and everything works fine.
I am surprised that I am the first to post this, being that I am not nearly as good as most people that post, I hope I am not messing anything up....
generate CRUD problem
I tried to generate the CRUD, but when I clicked "Preview", I received a page with this text:
render('index', array( 'dataProvider' => $dataProvider, )); } public function actionView($id) { $this->render('view', array( 'model' => $this->loadModel($id), )); } public function actionCreate() { $model = new TpContato; if (isset($_POST['TpContato'])) { $model->setAttributes($_POST['TpContato']); try { if($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('view','id'=>$model->
What's wrong?
I generated the models.
Application log, last trace:
Querying SQL: SHOW CREATE TABLE
tp_contato
in /home/bill/workspace/testdrive/index.php (13)
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.