Yii Framework Forum: Giix — Gii Extended - Yii Framework Forum

Jump to content

  • (14 Pages)
  • +
  • « First
  • 11
  • 12
  • 13
  • 14
  • You cannot start a new topic
  • You cannot reply to this topic

Giix — Gii Extended a code generator for Yii PHP framework (scaffolding/code generation) Rate Topic: ***** 4 Votes

#241 User is offline   Jonny 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 184
  • Joined: 26-December 11

Posted 05 April 2013 - 07:52 PM

Hi Rodrigo,

Just trying out Giix. So far i've just created all my models and CRUD.
Iit's been great for relational data. I have a small problem. In a my item view it links who created the item. But when I click on the link I get "include(item01.lister.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory"

'value' => $model->lister !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->lister)), array('item01.lister/view', 'id' => GxActiveRecord::extractPkValue($model->lister, true))) : null,


All the other FK links work fine though. What may I have done wrong? The Model and Controller both exist. I've even deleted them and regenerated them. All other models/controllers seem to be working fine.

Thanks

Jonny

EDIT: I wanted to really text Giix so I loaded a larger more comprehensive DB and went through and this problem didn't seem to happen. Not sure why, but it kind of resolved itself - Thanks

This post has been edited by Jonny: 07 April 2013 - 12:14 AM

0

#242 User is offline   TonyBoy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 23-December 12

Posted 07 April 2013 - 03:19 AM

More than one representingColumn.

Hello,

When I have more than one representing column, like:
	public static function representingColumn() {
		return array('country','prefix');
	}


Is there some better way to get the value for only one of the representing columns than to get all and then split like
explode('-',$string_representingColumn);

0

#243 User is offline   Jonny 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 184
  • Joined: 26-December 11

Posted 07 April 2013 - 02:31 PM

Hi

I have this new thread in the general framework questions as I'm not sure if it is necessarily a Giix problem. Could somebody let me know if this thread seems to be a Yii (In general) issue or Giix please.

Cdbexception Error Using Giix Generators

I can confirm that this seems to be a problem in Giix as i've redone everything with standard Gii and I can access the create/update/admin portions of every model, including the one that was producing the cdbException() error.

This post has been edited by Jonny: 07 April 2013 - 03:35 PM

0

#244 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 07 April 2013 - 07:08 PM

View PostJonny, on 05 April 2013 - 07:52 PM, said:

this problem didn't seem to happen. Not sure why, but it kind of resolved itself


Good to know, sorry for the delay.
0

#245 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 07 April 2013 - 07:12 PM

View PostTonyBoy, on 07 April 2013 - 03:19 AM, said:

Is there some better way to get the value for only one of the representing columns


Hi TonyBoy,

Please take a look at GxActiveRecord::__toString. It uses the value of the representing columns to build a string representation of your model instance. You can override this method to change the representation.

If you just want to change the separator, use GxActiveRecord::repColumnsSeparator.
0

#246 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 07 April 2013 - 07:13 PM

View PostJonny, on 07 April 2013 - 02:31 PM, said:

I have this new thread in the general framework questions as I'm not sure if it is necessarily a Giix problem. Could somebody let me know if this thread seems to be a Yii (In general) issue or Giix please.


I'll take a look there.
0

#247 User is offline   Naceur 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-February 13
  • Location:Tunisia

Posted 09 April 2013 - 12:14 PM

I have installed GIIX extension. I try to execute it with the following url/app/index.php/giix but it did not work?
any idea to run it plz?
0

#248 User is offline   gos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-April 13

Posted 09 April 2013 - 12:57 PM

Hi,

Thanks for your great extension and hard work. I was wondering if this extension is still being actively developed and if so if there is a roadmap for it? What are the plans/future for this extension? Will this continue to be enhanced and updated? Is there a chance that this extension (or something like gii-template-collection) will be a standard part of YII?

best regards, Gos
0

#249 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 09 April 2013 - 07:12 PM

View PostNaceur, on 09 April 2013 - 12:14 PM, said:

any idea to run it plz?


Please refer to the readme and install files, you'll get the info you need there.
It is important to understand how the framework works and how to use Gii. I recommend that you read the guide, too.
0

#250 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 09 April 2013 - 07:20 PM

View Postgos, on 09 April 2013 - 12:57 PM, said:

I was wondering if this extension is still being actively developed and if so if there is a roadmap for it? What are the plans/future for this extension? Will this continue to be enhanced and updated? Is there a chance that this extension (or something like gii-template-collection) will be a standard part of YII?


Hi Gos,

This extension is supported by me and by its users. You can ask questions here.
There is a private roadmap, but the development is currently suspended due to lack of time.
My plans for the future include a complete rewrite to launch giix 2 for Yii 2.0.

I don't know whether the core framework developers plan to integrate the features from giix or similar extensions into Gii. You should ask them instead.
0

#251 User is offline   fleuryc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 09-November 11

Posted 14 May 2013 - 08:38 AM

Hi!

Just a question : can I use saveWithRelated for a MANY_MANY relation with data. For instance :
Person(int id)-Seen(int id_person,int id_movie,date date,bool liked)-Movie(int id)


Can I use saveWithRelated to save one person with all the movies he has seen and the relation data (date and liked wich cannot be null)?

If not, how to do it nicely?

Cheers!
0

#252 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 16 May 2013 - 02:41 PM

saveWithRelated will save only the FKs.
You will probably have to save the models manually.
0

#253 User is offline   pineappleclock 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-May 13

Posted 18 May 2013 - 11:46 PM

Hi, I'm a Yii beginner.

I generated Giix CRUD on a Giix-generated model that had a relation to another model, namely the model from this extension: imagegallerymanager - "Gallery".

The Gallery model just extends CActiveRecord, so this piece of code fails:

<?php echo $form->labelEx($model,'gallery_id'); ?>


with "Gallery and its behaviors do not have a method or closure named "label".".

If I add the label static function in from GxActiveRecord, or even make the Gallery class extend GxActiveRecord, it just generates more errors, like complaining about findAllAttributes missing and a bad SQL string.

My question is: do all models in the application that have relations need to be GxActiveRecord, or can they mix and match? How would I make a Giix model work with a relation to this 3rd party extension model?
0

#254 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 19 May 2013 - 05:15 AM

pineappleclock, you can replace the "null" value for the keys "gallery_id" and "gallery" on getAttributeLabels on your model with a string. That will fix the error.
0

#255 User is offline   stelgenhof 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 06-January 09
  • Location:Zaandam, Netherlands

Posted 05 September 2013 - 09:18 PM

Hi,

Gixx offers a separated model and basemodel. Would it be possible to do the same for controllers?

Thanks! Sacha
0

#256 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 06 September 2013 - 05:46 AM

Models are separated so that you can re-generate the basemodel often after you change your database schema.
The generated controller has just minimal, example code. Most of it will be rewritten by you.
But all controllers generated by giix will extend a common class Controller.

If you still need separated controllers, you can modify the template giix uses to generate your code.
0

#257 User is offline   Ednei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 16-May 13

Posted 07 October 2013 - 01:03 PM

Hi!

I have a table with company's data and another table with the contact's data. So, I decided to use this great extension to generate my CRUD, but when I try to update some company with contacts I receive this error message: "Object of class Contato could not be converted to int" and this doesnt happen when the company doesnt have contacts.

Is this a bug or some incompatibility with yiistrap extension?

This is the stack trace:

PHP notice
Object of class Contato could not be converted to int

/opt/lampp/htdocs/polyafer-app2/protected/extensions/bootstrap/helpers/TbHtml.php(987)

975     	$checkAllLast = TbArray::popValue('checkAllLast', $htmlOptions);
976     	if ($checkAll !== null) {
977         	$checkAllLabel = $checkAll;
978         	$checkAllLast = $checkAllLast !== null;
979     	}
980 
981     	$items = array();
982     	$baseID = $containerOptions['id'] = TbArray::popValue('baseID', $htmlOptions, parent::getIdByName($name));
983     	$id = 0;
984     	$checkAll = true;
985 
986     	foreach ($data as $value => $label) {
987         	$checked = !is_array($select) && !strcmp($value, $select) || is_array($select) && in_array($value, $select);
988         	$checkAll = $checkAll && $checked;
989         	$htmlOptions['value'] = $value;
990         	$htmlOptions['id'] = $baseID . '_' . $id++;
991         	if ($inline) {
992             	$htmlOptions['label'] = $label;
993             	self::addCssClass('inline', $labelOptions);
994             	$htmlOptions['labelOptions'] = $labelOptions;
995             	$items[] = self::checkBox($name, $checked, $htmlOptions);
996         	} else {
997             	self::addCssClass('checkbox', $labelOptions);
998             	$option = self::checkBox($name, $checked, $htmlOptions);
999             	$items[] = self::label($option . ' ' . $label, false, $labelOptions);


– /opt/lampp/htdocs/polyafer-app2/protected/extensions/bootstrap/helpers/TbHtml.php(1719): TbHtml::checkBoxList("Empresa[contatos]", array(Contato, Contato), array(1 => "Ednei Rodrigues", 2 => "Matheus Benaia"), array("id" => "Empresa_contatos"))

1714     	}
1715     	$name = TbArray::popValue('name', $htmlOptions);
1716     	$unCheck = TbArray::popValue('uncheckValue', $htmlOptions, '');
1717     	$hiddenOptions = isset($htmlOptions['id']) ? array('id' => parent::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
1718     	$hidden = $unCheck !== null ? parent::hiddenField($name, $unCheck, $hiddenOptions) : '';
1719     	return $hidden . self::checkBoxList($name, $selection, $data, $htmlOptions);
1720 	}
1721 
1722 	/**
1723  	* Generates an inline check box list for a model attribute.
1724  	* @param CModel $model the data model.


/opt/lampp/htdocs/polyafer-app2/protected/extensions/bootstrap/widgets/TbActiveForm.php(379): TbHtml::activeCheckBoxList(Empresa, "contatos", array(1 => "Ednei Rodrigues", 2 => "Matheus Benaia"), array())
374  	* @return string the generated checkbox list.
375  	* @see TbHtml::activeCheckBoxList
376  	*/
377 	public function checkBoxList($model, $attribute, $data, $htmlOptions = array())
378 	{
379     	return TbHtml::activeCheckBoxList($model, $attribute, $data, $htmlOptions);
380 	}
381 
382 	/**
383  	* Renders an inline checkbox list for a model attribute.
384  	* @param CModel $model the data model.


– /opt/lampp/htdocs/polyafer-app2/protected/views/empresa/_form.php(79): TbActiveForm->checkBoxList(Empresa, "contatos", array(1 => "Ednei Rodrigues", 2 => "Matheus Benaia"))
74             	TbHtml::submitButton(Yii::t('app','Save'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY)),
75             	TbHtml::resetButton(Yii::t('app', 'Reset')),
76     	)); ?>
77     	
78             	<label><?php echo GxHtml::encode($model->getRelationLabel('contatos')); ?></label>
79     	<?php echo $form->checkBoxList($model, 'contatos', GxHtml::encodeEx(GxHtml::listDataEx(Contato::model()->findAllAttributes(null, true)), false, true)); ?>
80     	<label><?php echo GxHtml::encode($model->getRelationLabel('enderecos')); ?></label>
81     	<?php echo $form->checkBoxList($model, 'enderecos', GxHtml::encodeEx(GxHtml::listDataEx(Endereco::model()->findAllAttributes(null, true)), false, true)); ?>
82     	<label><?php echo GxHtml::encode($model->getRelationLabel('orcamentoServicos')); ?></label>
83     	<?php echo $form->checkBoxList($model, 'orcamentoServicos', GxHtml::encodeEx(GxHtml::listDataEx(OrcamentoServico::model()->findAllAttributes(null, true)), false, true)); ?>
84     	<label><?php echo GxHtml::encode($model->getRelationLabel('orcamentoVendas')); ?></label>

0

#258 User is offline   banago 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 10-March 11
  • Location:Piz da Dufour

Posted 25 October 2013 - 04:59 AM

Hi
I was recognizing that the giix generated base models where missing the label in representing columns. The related label was null.

I had the following constellation:

  • Labels in the base model where generated with Yii::t();
  • All attributes in the table where in lowercase e.g. tablename.myattribute
  • The generated attributes in the model e.g. Myattribute
  • Foreignkey attributes in this form: tablename.myattribute_id
  • The generated attributes in the model e.g. null


So how to get a correct label for the foreign-key columns in a table without changing the code of giix?

My solution is the following:

1.
Copy the folder recursively from default to your foldername:

protected\extensions\giix\generators\giixModel\templates\default\

e.g.
protected\extensions\giix\generators\giixModel\templates\mytemplates\


So you can select mytemplates before generating the models.

2.
Edit
protected\extensions\giix\generators\giixModel\templates\mytemplates\_base\basemodel.php


At public function attributeLabels()
Comment out or delete
<?php echo "'{$name}' => null,\n"; ?>

into
<?php //echo "'{$name}' => null,\n"; ?>

and therefore add the following code:
 <?php
        $labelRelated=$name;
        $labelRelated = str_replace('_id','',$labelRelated);
        $labelRelated = ucwords(strtolower($labelRelated));
        echo "'{$name}' => Yii::t('app','{$labelRelated}'),\n"; 
 ?>


And regenerate the basemodels with GiixModel Generator!
Maybe this is not a consistent solution to add to future versions of giix but at least it works and would not be overwritten from future updates.

Thats it.
B)

Keywords: attributeLabels, getRelationLabel, getAttributeLabel
0

#259 User is offline   eduardooliveos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-December 13

Posted 26 December 2013 - 09:45 AM

i used giix a few days ago, everything is ok but the accessrules not have place, i cant make start to generate privacity in some page, somebody know if i can implement this metod in giix and how?(excuse for my english not is my mother language)
0

#260 User is offline   ceejay 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 17-March 14

Posted 17 March 2014 - 03:29 PM

The empty parameter in the following line of code is ignored. I would like for this dropdown list to allow an empty value. The value is used to create a row in an association table, but creating a row is not always required.

<pre>
<?php echo $form->dropDownList($model, 'leads', GxHtml::encodeEx(GxHtml::listDataEx(Lead::model()->findAllAttributes(null, true)),array('empty'=>'-- Select Leads --'), true)); ?>

</pre>
0

Share this topic:


  • (14 Pages)
  • +
  • « First
  • 11
  • 12
  • 13
  • 14
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users