Awecrud

Just released a new version of AweCrud adding support for "defaultAction" property in controller.

Download it, Take a look and feel free to report any bug you find.

Go to AweCrud

Hi I have installed this extension but cannot get it to work in gii? it shows up on the left menu but when I click on either awemodel or awecrud I get the following error

"Error 404

Unable to resolve the request "gii/AweModel"."

I have added the extension to the protected/extensions folder, I have added it to the import array next to others, this si what my import array looks like


// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		'application.modules.user.models.*',

		'application.modules.user.components.*',

		'application.modules.rights.*',

		'application.modules.rights.components.*',

    'ext.AweCrud.components.*', // AweCrud components

	),

I have added it to my generator paths as shown below


'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'william1',

			

			// generator paths

        'generatorPaths'=>array(

        	'bootstrap.gii', // bootstrap yii booster

        	'ext.AweCrud.generators', // AweCrud generators

        ),

        

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

can anyone suggest why this doesnt work?

thanks in advance

wayne

Please check that you have something like this in your urlManager/Rules:





        'urlManager' => array(

            'urlFormat' => 'path',

            //'showScriptName' => false,

            'rules' => array(

                'gii' => 'gii',

                'gii/<controller:\w+>' => 'gii/<controller>',

                'gii/<controller:\w+>/<action:\w+>' => 'gii/<controller>/<action>',

...



Regards

Hi Ricardo thanks for the quick reply, I have checked my url manager and it all seems to be working fine, however I have pasted it below just in case you see something, I am not just having this problem with your extension but with others as well, and yet some extensions work? for example I have yii booster bootstrap extension and that works fine in the gii console, but others like yours do not work but they do appear in the left menu.


// url manager

		'urlManager'=>array(

      'caseSensitive' =>false,

 			//'showScriptName'=>false,

			'urlFormat'=>'path',

			'rules'=>array(

			

			// main index

   			'/' => 'site/index',

   			

   			// login / logout / register / forgot password / forgot username

   			'Login' => 'user/login',

   			'Register' => 'user/registration',

   			'Forgot-Password' => 'user/recovery',

   			

   			// user section

   			'Profile/<id:\d+>' => 'user/profile',

   			

   			'Contact' => 'site/contact',

   			

   			'About' => array('site/page', 'defaultParams' => array('view' => 'about')),

			

	// gii url

            'gii'=>'gii',

            'gii/<controller:\w+>'=>'gii/<controller>',

            'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',

   			

   			// default url code

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

again thanks for any help

wayne

I’m not sure about the reason of this error, however, I recommend to move “’/’ => ‘site/index’,” to the very bottom, just above “//default url code”.

It maybe helps.

thanks Ricardo I tried that but still get the error, I have tried to install a few other gii extensions such as giix and gtc but they are the same at least for model and crud, some of the other generators in gtc work?

just in case it is relevant I am running this yii on my windows 7 machine with xamp 1.8.1 and PHP Version 5.4.7 and Apache/2.4.3 (Win32)

I have even tried it on a brand new app (testdrive) created from the command propt in framework and still get the 404

regards

wayne

Pretty weird…

Can you post a screenshot with the error message? Maybe we can help.

there is no real error just a 404 I but have included a screenshot of screen and also of the error part in the CWebLogRoute

regards

wayne

@bbunlock Were you able to find the reason of the bug?

Hi,

I’ve just installed the new versio of AweCrud, and now while generating crudCode, I’ve got:


Undefined variable: model 

in: protected/extensions/AweCrud/generators/AweCrud/templates/default/_form.php(9)

Could you please post all the backtrace?

Thanks.

This bug will be fixed in the next release. Hopefully in a few hours.

Thanks for reporting.

Last version released, please feel free to download from Exntesions page: http://www.yiiframew…ension/awecrud/

Thank you. It Works well now.

Glad to hear that it it working well.

Version 0.9 released. Feel free to download and report any bugs you find.

Getting this error after generating CRUD

Declaration of ListingController::loadModel() should be compatible with AweController::loadModel($key, $modelClass)

Have the latest Yii release and on PHP 5.4. Any suggestions?

EDIT:

Another error when attempting to generate crud for another table. Which has a primary key.

Undefined variable: identificationColumn

\protected\extensions\AweCrud\generators\AweCrud\templates\default\_view.php(72)


60             <div class="field_value">

61                 <?php if (in_array($column->dbType, $this->dateTypes)): ?>

62                 <?= "<?= Yii::app()->getDateFormatter()->formatDateTime(\$data->{$columnName}, 'medium', 'medium') ?>\n" ?>

63                 <br/>

64                 <?= " <?= date('D, d M y H:i:s', strtotime(\$data->" . $columnName . ")) ?>\n" ?>

65                 <?php elseif (in_array($column->dbType, $this->booleanTypes)): ?>

66                 <?= "<?= CHtml::encode(\$data->{$columnName} == 1 ? 'True' : 'False') ?>\n" ?>

67                 <?php elseif (in_array(strtolower($columnName), $this->emailFields)): ?>

68                 <?= "<?= CHtml::mailto(\$data->{$columnName}) ?>\n" ?>

69                 <?php elseif (in_array($column->dbType, array('longtext'))): ?>

70                 <?= "<?= nl2br(\$data->{$columnName}) ?>\n" ?>

71                 <?php elseif (in_array(strtolower($columnName), $this->imageFields)): ?>

72                 <?= "<img alt=\"<?= \$data->{$identificationColumn} ?>\" title=\"<?= \$data->{$identificationColumn} ?>\" src=\"<?= \$data->{$columnName} ?>\" />\n" ?>

73                 <?php elseif (in_array(strtolower($columnName), $this->urlFields)) : ?>

74                 <?= "<?= AweHtml::formatUrl(\$data->{$columnName}, true) ?>\n" ?>

75                 <?php else : ?>

76                 <?= "<?= CHtml::encode(\$data->{$columnName}) ?>\n" ?>

77                 <?php endif; ?>

78             </div>

79         </div>

80 

81         <?php if (!in_array($column->dbType, $this->booleanTypes)): ?>

82             <?= "<?php endif; ?>\n" ?>

83             <?php endif; ?>

84         <?php endif; ?>

Thanks

Sean

First of all, please, make sure you are using the last version of AweCrud (version 0.9).

And now, could you please post the generated code with the error? if you can post the table fields and the model it would be great too.

I’m currently fixing the “_view.php line 72” bug, that it’s due to the generator detected an “image” field. A workaround cold be to comment lines 71 - 72.

Regards.

Another good (& functional) workaround is to replace line 72 to:




<?= "<img alt=\"<?= \$data ?>\" title=\"<?= \$data ?>\" src=\"<?= \$data->{$columnName} ?>\" />\n" ?>



Regards

New version 0.10 released! It fixes several bugs when PHP 5.2 is used (thanks to @franhb).

Also it fixes the bug with the images link reported by @Sean.

Feel free to download it and report any bugs you find.