while generating a model, i got this exception(r2008):
CException
Description
Property "ModelCode.controller" is not defined.
Source File
C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\yii\dev\framework\gii\generators\model\ModelGenerator.php(9)
00001: <?php
00002:
00003: class ModelGenerator extends CCodeGenerator
00004: {
00005: public $codeModel='gii.generators.model.ModelCode';
00006:
00007: public function getSuccessMessage($model)
00008: {
00009: $link=CHtml::link('try it now', Yii::app()->createUrl($model->controller), array('target'=>'_blank'));
00010: return "The controller has been generated successfully. You may $link.";
00011: }
00012: }
We all know that no single code copy will fit for all needs and for all people.
Gii allows you to easily develop and use your own code templates for generating code.
For example, in your phundament project, you may create some code templates under your application’s folder so that the generated code can play well with your application.
We may consider supporting downloading the source files in a zip package, if more people are requesting for this feature.
Regarding 403 error, I guess it’s caused by mismatching of your IP address? The default security filter will only allow 127.0.0.1.
Yeah, we did expect some upgrade pain due to the change of the code generators when we released 1.1.
We are facing a paradox, i.e., we either have to stick to the old behavior with less features, or we have to introduce some external dependency in order to implement some common features in the generated code.
The ultimate solution is gii which supports multiple sets of code template for different needs.
Don’t sacrifice features for backward-compatibility, the decision was fine.
I played around with gii a little bit more and now I got it
Applying the gii-style to phundament wasn’t a big deal. I’ve just renamed main.php to main2.php as a quick fix.
But the almost ultimate solution would be if the genereated code could be created with a theme.
As mentioned I added Controller.php to phundament to test the new CRUDs and gii, but I actually do not really use it elsewhere.
So I added there:
<?php
class Controller extends CController {
public $breadcrumbs = null;
public $menu = null;
public function init(){
Yii::app()->theme='yii-1.1';
}
}
?>
And copied the needed files to this theme location.
Phundament comes with a component called EAutotheme which manages the inclusion of CSS and JS files.
btw: This was the first thing I wrote in yii, because I missed this feature from PRADO .
Anyway … I got one more glitch at the moment, and the reason it is not working is that I am unable to overwrite the layout in the theme. I placed it in the themes location, but the path is too specific I think, and beginContent() does not differentiate between layouts and views.
Maybe I’ve to dig into this a bit more … but if just the layout, CSS and JS files could be delivered within a theme, we could get a pretty clean solution here.
Maybe, a chooseable BaseController for the CRUDs would also help.
oh very nice only 1 issue I have where it creates the post vars with lowercase but the model classes with upercase… so by default it never saves anything
Also it seems to ignore the not null any fields for validation.
Could you explain in more details? "… it creates the post vars with lowercase but the model classes with upercase… so by default it never saves anything…"
My table names are in lowercase… but class name with uppercase (the model) When i create the CRUD it will create post / get vars in the controller like:
$model->attributes=$_POST[‘pages’];
instead of:
$model->attributes=$_POST[‘Pages’];
So it never saves anything and no error message.
Love the diff files btw… very usefull in early development when the data model is not fixed yet.
btw something different… with the svn version not sure other… the font for the captcha seems to be always be used by apache cannot delete it without stopping the apache service.
Also the ajax validation does not work anymore… as in 1.1.1 with CLI
Extending gii comes in several ways. The most common way is to provide your own set of templates for the existing generators. Let’s assume you want to do this for the “crud” generator.
Create a directory “protected/gii/crud/templates/compact”. The name “compact” refers to the name of the template set you want to create. If you don’t like the ‘default’ template at all and want to replace it with your own, you can name the new template set to be ‘default’.
Copy all files from "framework/gii/generators/crud/templates" to this directory.
Modify the copied files as you want. You may even delete some of them if they are not needed.
Modify your app config and add “application.gii” to the ‘generatorPaths’ property of the gii module.
I also had it like that, btw: application.gii is the default and system.gii is always added to the scandirs first, right?
When I var_dump $generator in findGenerators() I see that first it’s filled with the templates from system.gii, and those are erased, when application.gii is scanned, even though the template has a different name.
I just expected it in a different way, would be cool to have the defaults available.
Another thing, could you update this in the gii module: column1.php and generator.php