Giix — Gii Extended

mentel, the behavior he’s describing makes sense in a Many-to-Many relationship, but not in a One-To-Many relationship, the kind you would expect between Customer and Orders. Does giix behave the same for Many-To-Many and One-To-Many relationships?

I recently came across your extension and thought I’d see what it provided above and beyond gii. I’ll be playing with it soon in a test environment. Thanks!

The generated code, in this case, is more like an example.

The behavior will be defined by your own code.

Giix is awesome mentel, great job!

I’ve been working for several days on implementing my own many-many CRUD without success. Finished it in 30 mins with help of Giix. :)

Looking forward to see ticket 7 for even more awesomeness.

I think it should be added to Yii and replace Gii, I bet many people don’t know about extensions and therefore misses this one.

Keep the good work up.

I think I’ve found a bug in how Giix displays boolean values in the admin CGridView view.

The affected columns in my database have the type tinyint(1) and ofcourse have the values 0 or 1.

But despite if the value is 0 or 1 it is shown as ‘Yes’ in the table. The dropdown filtering works correctly, filtering all 0 values when ‘No’ is selected, and the other way around.

A column entry in the CGridView widget in admin.php looks like




// ...

array(

	'name' => 'isDefault',

	'value' => '($data->isDefault === 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',

	'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),

),

// ...



I solved it by




// ...

array(

	'name' => 'isDefault',

	//'value' => '($data->isDefault === 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',

	'type' => 'boolean',

	'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),

),

// ...



Feels strange if this is a bug that have slipped under everyones radar, maybe I am doing something wrong?

I am using Yii 1.1.7 by the way.

Some ideas for the crud part that would be useful for me and aren’t in the issues already at google code:

-When creating a new entry and having to select something from another table, the ability to quickly create a new entry in the other (related) table which is then automatically selected in the first entry form. Possibly cascaded.

-I find the representingColumn() function quite restricting. So far I have been unable to insert arbitrary text or columns from another related table.

-I don’t know whether it’s a problem with me, my database or something else, but I can’t seem to set a foreign key back to null. When you have a dropdownlist you always have to select something.

I don’t know whether these ideas are ‘worthy’ of being added to the issues at google code, but I wouldn’t mind adding them if they are.

Hi Doru (mongoose76) and Thiago (Athos),

I have just finished and committed an improvement to giix: the support to labels for active records.

This change will allow:

  • The centralized management of the model and relation labels: you change it in the model and the change will be reflected in the views;

  • Better i18n and number (plural) management: when you implement your model’s “label” method, you can set it to use the Yii::t method and vary the source string according to the “$n” parameter.

Please check the GxActiveRecord::label, GxActiveRecord::getRelationLabel and GxActiveRecord::getAttributeLabel methods and their documentation.

To implement the "label" method in your model, see the GxActiveRecord::label documentation and the guide page on i18n/plural forms format.

To use in the views, use the GxActiveRecord::getRelationLabel (recommended most of the time) or directly the model::label methods.

I’d like to know your opinion regarding this enhancement and if it works well for your issues.

Please check the trunk code (revision 117) out and play around with it.

In the meantime I’ll work on the generation code and on the templates to leverage this new functionality.

Thanks!

Dear,

giix 1.8 is out!

And I feel you will like it. Improvements:

  • Labels for models and relations! See the post above for details.

  • Documentation improvements (for you who like to check the source code).

Don’t forget that you must implement the “label” method on each AR that extends from GxActiveRecord when upgrading.

Download it right now!

Dear,

giix 1.8 have a bug: it will throw an exception if you use class properties and request a label for it in a view.

The exception text will look like:

The fix is already online in the code repository, in the trunk. The fix was made in the revision 140.

Thanks Athos for reporting it.

Wow mentel, you are keeping me busy just keeping up with your updates. This is not a complaint at all. Thanks again for all the active work you are putting into this. Been using it for awhile now and love what it has to offer. Time to go and get 1.8 and implement that today!

mentel,

I am not sure I am understanding the approach to labels now. I have went to r1.8 and updated code to r140. Then used giix to create new models and CRUD.

On forms if I have a text input it will use the


public function attributeLabels() { 

for labels as in previous versions. On dropdowns or checkboxes it will use a case conversion of the Model (i.e. SubCategory = Subcategory) where that dropdown is filled from.

Does this mean that I need to modify the generated code for every attribute now that is not from a text field? I am not seeing what needs to be done here to get my labels back to using a simple input like


public function attributeLabels() { 

in the Model.

I know you mentioned this but with newly generated giix models it is there so I think I got that covered although I do need to read up to understand the logic a bit. Maybe that is where my solution is I don’t know.

Thanks

enfield,

There are some problems with this implementation. Athos have told me about some problems he is having, too.

Please use giix 1.7 until they are fixed (on 1.8.1 or 1.9).

Thanks for understanding.

mentel, no problem. I poked around a bit more and did some additional reading. I think I have a basic understanding of what you are after here and I think it is a great improvement. Easy enough to continue using 1.7 for now.

Dear mongoose76, Athos and enfield,

I finished the updates in the code for proper support to the labels functionality and I’d like to have some opinions and tests.

Could you please check giix out, see the code and perform some tests to check if it is working as it should now?

See the last commit (rev 150) at

http://code.google.com/p/giix/source/detail?r=150

Thank you!

Hello,

I’ve set up giix, and login to gii module.

while I’m trying to generate a model using giixmodel generator I’ve got this error

"Property "CMysqlColumnSchema.autoIncrement" is not defined."

I’ve also got the same error while I’m trying to use giix crud using my old modules. While the gii is working fine.

any ideas?

Thanks

Please open a new issue at Google Code and include the information that is asked there.

With that information, I can help you and fix the possible bug.

Thank you!

New version: giix 1.9

Dear,

giix 1.9 is here, and it gives you a smooth experience with active record and relation labels.

This new version improves the labels feature introduced in giix 1.8 and delivers the functionality with performance and flexibility. Give it a try!

I appreciate your votes, keep voting! :)

Don’t forget that you must implement the “label” method on each AR model that extends from GxActiveRecord when upgrading. See the UPGRADE file for more information.

Download giix 1.9 right now!

mentel, I will roll this into an app and test things out over the next couple of days.

I have a question for you also in regards to:


echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)),

  array('model/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));

How can I still utilize this but remove the link?

Thank you!

Please let me know your feelings about it.

Just remove the call to GxHtml::link. The result:


echo GxHtml::encode(GxHtml::valueEx($relatedModel))

Man I was over thinking that one, trying to get it working while keeping extractPkValue in play. Thanks for the quick help.

mentel since this


foreach($model->relation as $relatedModel) {

  echo GxHtml::valueEx($relatedModel);

will default to using the representingColumn(), what is the trick to loading a different attribute instead without changing the representingColumn?