Giix — Gii Extended

Perhaps this is a bug? When I generate Models using Giix it doesn’t seem to add any validation rules for columns of type text, meaning I have to manually add those rules in to the model in order to pass validation methods.

i.e. GiixModel and GiixCrud don’t work out of the box with each other (because GiixCrud uses $model->setAttributes($_POST[‘Column’]) and without the validation rules, no columns of type Text are updated).

Hi ajberri, please open a new ticket with all details so I can take a look at it.

Hi,

I was wondering about the composite PK on the roadmap.

Will this be done "sometime soon" for CRUD?

If so, will it work for the existing yii code?

If not, what is the estimated effort for the average programmer to implement it?

have a nice day!

Hi yiivert,

There’s no plan to have complete support for composite PK. Also, I can’t estimate the effort it would take. You’re welcome to check the source code and code this. giix source code is well documented. Then, if you want to contribute your work back to giix, I’ll gladly take your patches.

Hello. First off, thanks very much for this extension to Gii. It’s saved me tons of time already.

I’ve got a question that’s been asked before (on this thread too), but that I can’t find the answer for. Can you post a working example of how to use the saveMultiple() function? I’ve figured out how to save a MANY-to-MANY, but can’t find any examples of how to save a HAS_MANY or BELONGS_TO relationship.

In a hypothetical situation where I was updating a Comment view/model that also allowed updating the related BELONGS_TO Post for that comment, this is the code I’ve tried.




public function actionUpdate($id) {

	$model = $this->loadModel($id, 'Comment');




	if (isset($_POST['Comment'])) {

		$model->setAttributes($_POST['Comment']);

		

		$post = new Post();

		$post->setAttributes($_POST['Post']);


		$relatedData = array(

			array(

				'model' => $model,

				'modelOptions' => array(

					'attributes' => $_POST['Comment'],

				),

			),

			array(

				'model' => $post,

				'modelOptions' => array(

					'attributes' => $_POST['Post'],

				),

			),

		);


		if ($model->saveMultiple($relatedData)) {

			$this->redirect(array('view', 'id' => $model->id));

		}

	}

}



But everytime I try it, I get an error:




Fatal error: Using $this when not in object context in protected/extensions/giix-components/GxActiveRecord.php on line 578



Any suggestions? Thanks! Oh, by the way, I’m running GiiX 1.9.1

I have a problem with giix, i reinstall mysql, php and apache services, and now i have a problem with the giix crud generator , it is not opening, but its so weird because the giix model generator works fine, the error in the navigator is:

Error 101 (net::ERR_CONNECTION_RESET)

i try cleaning assets and the content of the runtime folder but nothing happens, it still with the same error

please help, i love this ext

Very strange. Please open a new ticket with all the information asked there. Thanks!

Hi fr0d0z,

Unfortunately, [font="Courier New"]saveMultiple[/font] has a few bugs that I just discovered. Please save the records manually.

Thanks mentel, that’s what I’m doing for now. But thanks again for GiiX, it’s saving me tons of time.

First of all, thanks a lot for this very usefull extension!! I’m new to Yii, so please forgive me if I’m bothering you with this (if it should not be a bug…)

I’ve installed giix and started using it. The GiixModel Generator works just great. But when I try to use the GiixCrud Generator I run into this:

  1. I click on the Link "GiixCrud Generator" on the gii page (index.php?r=gii)

  2. This opens up GiixCrud Generator page, but this page is broken. Only a few HTML lines are shown:


<h1>giix Crud Generator</h1>


<p>This generator generates a controller and views that implement CRUD operations for the specified data model. </p>


<div class="form gii">

	<p class="note">

		Fields with <span class="required">*</span> are required.

		Click on the <span class="sticky">highlighted fields</span> to edit them.

	</p><form id="yw0" action="/saja_cms/index.php?r=gii/giixCrud" method="post">


	<div class="row">

		<label for="GiixCrudCode_model" class="required">Model Class <span class="required">*</span></label>        

There are no <head> tags, no css styling, no form is displad etc. Only what I’ve posted above. I’ve tested it on two different servers and run into the same problem.

Did anyone have this problem as well? I’m using the latests version of Yii (1.1.10).

Your help is very appreciated! I’d really like to use the crud functionality of giix, it would save me a lot of time.

Thanks for your help.

Hi!

I’ve the same problem with GiixCrud.(The browser run to ERROR :: 101.) I use new WAMP with a ‘virgin’ yii and sql shema.

With xampp there is no problem with it. Maybe it 'couse WAMP permissions.

If you find new issues, please open a new detailed ticked.

Please remember that I can’t support WAMP, xampp etc.

Rodrigo, any chance you might be moving GiiX to Github at some point? With the change of Yii to Github, it might be easier for us to submit pull requests to you if you were using Github as well. Just a thought.

Yes, it will. It is planned already.

I can (and want) take giix there, but I’m so busy with another project right now that we won’t benefit much in the short term.

As soon as there’s some space in the current project, giix will hit GitHub. I look forward to the community’s pull requests :)

Meanwhile, you can post issues and patches to Google Code.

Thanks!

Just started experimenting with Yii and found the excellent Giix, great work!

I’ve been had the same issue as Nymphetamine, domo & TimLeary, with giixCrud giving browser error 101, (I’m also using WAMP), thought I should register on the forum to share my fix.

I’ve worked around the issue by editing extensions/giix-core/giixCrud/views/index.php to comment out the autocomplete input for model and replace with a normal text field:


<!--    <?php $form->widget('zii.widgets.jui.CJuiAutoComplete', array(

            'model'=>$model,

            'attribute'=>'model',

            'source'=>$this->getModels(),

            'options'=>array(

                'delay'=>100,

                'focus'=>'js:function(event,ui){

                    $(this).val($(ui.item).val());

                    $(this).trigger(\'change\');

                }',

            ),

            'htmlOptions'=>array(

                'size'=>'65',

            ),

        ));

        ?> -->

        <?php echo $form->textField($model,'model',array('size'=>65)); ?>

My first guess would be the issue relates to the scandir function in getModels of GiixCrudGenerator, underscore in directory name is unusual for a windows system, maybe it’s the _base folder but that’s just a guess I don’t really have time to investigate further.

Hope that helps.

How can you do a LOG for every action done in the database?

Before Giix I was using a class extending CActiveRecordBehavior and it was working, but now I can’t make it to work with Giix…

Can you help me out?

This is my DBLog.php in the folder components




<?php


class DBLog extends CActiveRecordBehavior {

    

    public function afterSave($event) {

        if (!$this->Owner->isNewRecord) {

            $log = new Log;

            $log->id_user = Yii::app()->user->id;

            $log->id_model = $this->Owner->id;

            $log->title = get_class($this->Owner);

            $log->action = 'CHANGE';

            $log->date = date("Y-m-d G:i:s",time());

            $a=$log->save(false);

            if (!$a) echo $a->getErrors();


        } else {

            $log = new Log;

            $log->id_user = Yii::app()->user->id;

            $log->id_model = $this->Owner->id;

            $log->title = get_class($this->Owner);

            $log->action = 'CREATE';

            $log->date = date("Y-m-d G:i:s",time());

            $a=$log->save(false);

            if (!$a) echo $a->getErrors();

        }

    }


    public function afterDelete($event) {

        $log = new Log;

        $log->id_user = Yii::app()->user->id;

        $log->id_model = $this->Owner->id;

        $log->title = get_class($this->Owner);

        $log->action = 'DELETE';

        $log->date = date("Y-m-d G:i:s",time());

        $a=$log->save(false);

            if (!$a) echo $a->getErrors();

    }


}


?>




HI there… Im experiencing the same problem, did you find a solution for this?

i confirm it’s a wamp problem, i try withe firefox,chrome, IE , start / stop wamp … no success

so i’ve download UwAmp, with the same code … no error !!

it’s definitly a wamp problem

i want to create another another post, speaking of many/many realtion.

I don’t understand why Giix use checkbox in the _form, it’s works so better with a multi select …

for that i’ve modified the :

"protected\extensions\giix-core\giixCrudGiixCrudCode.php"

around line 144 :




replace : 


return "echo \$form->checkBoxList(\$model, '{$relationName}', GxHtml::encodeEx(GxHtml::listDataEx({$relationModel}::model()->findAllAttributes(null, true)), false, true))";

with : 


return "echo \$form->listBox(\$model, '{$relationName}', GxHtml::encodeEx(GxHtml::listDataEx({$relationModel}::model()->findAllAttributes(null, true)), false, true),array('multiple'=>'multiple'))";



it work with multiselect, saved and all fine, it’s required …

The only problem is i get a php notice on the controler

just after each action i need to manually make a :

if (!isset($_POST[‘XXX’][‘YYY’]))

&#036;_POST['XXX']['YYY']='';

for information i’ve searched to translate the message :

1°: create protected\messages\fr\app.php

2°: copy the structure of yii\framework\messages\fr\yii.php

3°: enjoy the Giix Multilanguage !

ps : i’m french sorry for mistakes