Giix — Gii Extended

I found a problem when the relationship is not required and is not satisfied.

The solution is to check below:

GxHTML.php line 120


if (is_object($model) && $attribute === null)

Hi,

First of all thanks for this extension, I am using it and it is very cool.

I want to share a very small idea that I had with the rest of the group, maybe someone will find it useful or maybe you include it in the extension. If this is not the correct place point me in the right direction. In the meantime I will explain.

I am doing a back-office interface in my native language, Romanian. My database is in Romanian as well so the plurals of the models sound ridiculous so I have to always change them after I re-generate with giix CRUD. I re-generate a lot since I am playing around with the templates. Now, the solution I found to not change manually the resulting names is to extend the pluralize method in GiixCrudCode.php with the following:




public function pluralize($name) {

	return Yii::t("app", parent::pluralize($name));

}



This will hard-code the translated plural in the resulting CRUD files, but that’s exactly what I want to achieve. Of course you need to have internalization enabled in your project and an app.php file with the translations you want in the messages folder.

With a little change to the templates i18s support can be added so the plurals are taken from the messages files at runtime rather than generate time.

Hope this helps someone.

Doru P.

Hi Doru,

I’ve done differently. I created two more fields to inform the Portuguese name of the screen and the plural word.

This was necessary due to the massive use of special characters in my language and the database model should not be used.

Where have you placed these fields? In the database?

In the form of generation of CRUD. They will only be used in generation time and are not stored.

Aha. Well, seems like a workable solution, so there u go, people have two ways of solving the pluralize problem and maybe more. Plurals in English are easy but in Romanian it is hard to determine since they reply on the gender of the word. Very hard to determine, so it is much more easy to just provide it.

Hope this helps someone, I am trying to give something back to the Yii community since this is by far the best framework I have ever worked with. It has absolutely everything I need from a framework.

I had a problem while using the relation widget/extension and the update/create function generated:


$relatedData = array(

				'cmsMedias' => $_POST['CmsContent']['cmsMedias'] === '' ? null : $_POST['CmsContent']['cmsMedias']);

was generated. The Problem is [‘cmsMedias’] that should be [‘CmsMedia’] to work with the widget. Maybe there is a way to include the relation widget or to make it compatible?

I also have a Problem with the create part. the relational data is not updated, yii stays on the create form pafe with no message and no error. the update function is working. any ideas?

I too am experiencing this problem. The root of the problem is that the id (primary key value) of the record that was just created is missing. I am investigating a solution. Anyone else already fix this?

Cheers,

Keith

I was able to fix the issue where saving a new record with related data was failing. For details and the patch, please check out the issue I created on the giix Google Code site: http://code.google.com/p/giix/issues/detail?id=5

By the way, I created another issue because deletes would not work if you had foreign key constraints in your database. I wrote a beforeDelete function to automatically delete MANY_MANY, HAS_MANY, AND HAS_ONE related data so the main model record will delete without violating any foreign key constraints. You can get the patch here: http://code.google.com/p/giix/issues/detail?id=4

Cheers,

Keith

You able to to make the saveWithRelated() work with an attribute as safe in rules()?

See the original problem here:

http://www.yiiframework.com/forum/index.php?/topic/16744-activedropdownlist-with-the-options-selected-correctly-when-posted/page__p__83060

just a hint to the developer: plese check if the performAjaxValidation catches the request or not. If not, this may be the solution to the mentioned duplicate entry Bug. I had this within the gii-template-collection, too.

I preferred to use the eadvancedarbehavior extension instead of saveWithRelated().

I just used this extension recently it has few small bugs as I took code from repo , it really perform well with Many to Many.

it has issue with Form like it dont generate id to edit or view from grid and in views it creates issue with breadcumbs and menu(I just defined these varaibles in controler then it works smooth)

Very amazing App , True Code Generation is on the way

Sajid

Dear,

I’ve been very busy lately, but I hope I can resume working in giix soon.

There are some pending bugfixes (some are already fixed in trunk, check there!) and the roadmap is huge. Great things will come.

Please keep the comments, suggestions and bug reports (and patches if you can) coming!

Thank you,

Rodrigo Coelho - mentel

I’ve got a question.

I have 3 tables :


CREATE TABLE `utilisateur` (

	`id_utilisateur` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

	`login` VARCHAR ( 30 ) NOT NULL ,

	UNIQUE ( `login` )

)


CREATE TABLE `developpeur` (

	`id_utilisateur` INT( 9 ) NOT NULL ,

	`id_projet` INT( 9 ) NOT NULL ,

	`notification_email` TINYINT(1) NOT NULL DEFAULT '1' ,

	PRIMARY KEY ( `id_utilisateur` , `id_projet` ) ,

	FOREIGN KEY ( `id_utilisateur` ) REFERENCES `utilisateur` ( `id_utilisateur` )  ,

	FOREIGN KEY ( `id_projet` ) REFERENCES `projet` ( `id_projet` )

);


CREATE TABLE `projet` (

	`id_projet` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

	`nom_application` VARCHAR( 50 ) NOT NULL ,

	UNIQUE ( `nom_application` ),

);

Then one ‘utilisateur’ can activate the email notification on a ‘projet’ linked by the table ‘developpeur’.

I want to create on the user form an option to activate or not the email notification on linked project.

I use tour extension.

What’s the best way to do it ?

Btw I didn’t understood your method ‘pivot’, could it help me ?

Thx

Dear,

giix has a new version: 1.5!

Go download it right now!

Several bugs were fixed (thanks for the reporters!) and some new functionality were added, including:

Native support for saving multiple (related or not) records with the new method GxActiveRecord::saveMultiple.

This method allows you to save many models at once, in a transaction (if you want) in a painless way. Try it!

It can even automatically detect all new active records having a BELONGS_TO relation and fill in the data for their FK. Awesome.

Now GxController::performAjaxValidation supports multiple models. :)

What are you waiting for?

Don’t forget to vote.

Dear,

giix version 1.6 is released!

Go download it right now!

Improvements:

All known bugs fixed.

More automatic magic.

More flexibility.

More support to composite PK tables (but still incipient support).

giix is evolving fast. Stay tuned!

Download giix and vote it up!

Please help me

I got error yet when I try to delete a record in MANY TO MANY RELATION [giix v1.6 and Yii v1.1.7]




CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`tnewsnew`.`tbl_news_category`, CONSTRAINT `fk_newscategory_category` FOREIGN KEY (`category_id`) REFERENCES `tbl_category` (`id`) ON UPDATE CASCADE). The SQL statement executed was: DELETE FROM `tbl_category` WHERE `tbl_category`.`id`=4 



Hi,

It is not a giix issue. You have a FK constraint failing. You have "on update cascade" setup, you may want "on delete cascade", too.

Hello Mentel,

I have been using the extension and am very pleased.

I made some adjustments to suit me better. See below for their opinions on the possibility of deploying them officially:

  • In the page of view’s action, before listing the relations, with a tag <h2> highlight that these are dependent or related records.

  • On the generation of CRUD, include two more fields. To enter a screen name in my language and the other for the plural name. You know in any language other than English you can not retrieve the correct name of the nomenclature of the database.

  • For the same reasons, can not catch the names of the attributes directly from the data model. Then the method attributeLabes should not stay on the base file, since it must necessarily be changed. If he remains at the base, can not be the goal of these files remain intact.

  • Many databases have fields in each table to log user actions. I then created a method (getEditableColumns) to always ignore them in loops over the columns of the table, not to create the inputs and validations on the form, for example.

  • At least for me it was very important to change the method model->search() to do a merge with other default options passed as parameter.


Em português:

Olá Mentel,

Venho utilizando a extensão e estou muito satisfeito.

Fiz algumas adaptações para me atender melhor. Seguem abaixo para sua avaliação sobre a possibilidade de implantá-las oficialmente:

  • Na tela da action view, antes de listar as relações, destacar com uma tag <h2> que se tratam de registros dependentes ou relacionados.

  • Na tela de geração do CRUD, incluí mais dois campos. Um para digitar o nome da tela no meu idioma e o outro para o nome no plural. Você sabe que em qualquer língua que não seja o inglês não dá para recuperar o nome correto da nomenclatura do banco de dados.

  • Muitos bancos de dados têm campos para log em cada tabela. Criei então um método (getEditableColumns) para sempre ignorá-los nos loops sobre as colunas da tabela, para não criar os inputs e as validações no formulario, por exemplo.

  • Pelo mesmo motivo citado acima, não dá pra pegar os nomes dos atributos direto do modelo de dados. Então o método attributeLabes não deveria ficar no arquivo base, já que ele necessariamente deverá ser alterado. Se ele permanece na base, não consegue-se o objetivo desses arquivos permanecerem intactos.

  • Pelo menos para mim, foi muito importante alterar o método model->search() para fazer um merge das opções padrão com outras passadas como parâmetro.