Gii Template Collection

I’m getting this error every time i generate a full CRUD from a full MODEL of Gii Template Collection: http://www.yiiframework.com/extension/gii-template-collection/

Here are the first lines of the error:

[color="#FF0000"]Property "OrgaoEmissor.id" is not defined.[/color]

Source File

C:\wamp\www\yii\framework\db\ar\CActiveRecord.php(110)

00098: */

00099: public function __get($name)

00100: {

00101: if(isset($this->_attributes[$name]))

00102: return $this->_attributes[$name];

00103: else if(isset($this->getMetaData()->columns[$name]))

00104: return null;

00105: else if(isset($this->_related[$name]))

00106: return $this->_related[$name];

00107: else if(isset($this->getMetaData()->relations[$name]))

00108: return $this->getRelated($name);

00109: else

[color="#FF0000"]00110: return parent::__get($name);[/color]

00111: }

OrgaoEmissor is a table related with Client. I generate full model and crud for both but then this error appears, can someone help me? Is it a relationship problem within the database?

have you tried the latest SVN version?

http://code.google.com/p/gii-template-collection/

No, im doing it now thanks you.

Is there a complete documentation that i can read in order to solve this little issues?

I must be doing something wrong…

I ended with a problem that look alike the previous:

[color="#FF0000"]Property "OrgaoEmissorController.pickleForm" is not defined.

Source File

C:\wamp\www\yii\framework\base\CComponent.php(264)[/color]

00252: * @since 1.0.2

00253: */

00254: public function __call($name,$parameters)

00255: {

00256: if($this->_m!==null)

00257: {

00258: foreach($this->_m as $object)

00259: {

00260: if($object->getEnabled() && method_exists($object,$name))

00261: return call_user_func_array(array($object,$name),$parameters);

00262: }

00263: }

00264: if(class_exists(‘Closure’, false) && $this->$name instanceof Closure)

00265: return call_user_func_array($this->$name, $parameters);

00266: throw new CException(Yii::t(‘yii’,’{class} does not have a method named “{name}”.’,

00267: array(’{class}’=>get_class($this), ‘{name}’=>$name)));

00268: }

00269:

00270: /**

00271: * Returns the named behavior object.

00272: * The name ‘asa’ stands for ‘as a’.

00273: * @param string the behavior name

00274: * @return IBehavior the behavior object, or null if the behavior does not exist

00275: * @since 1.0.2

00276: */

I’m using the latest version of yii framework and gii template collection and still have this erros with pickleform.

Is there someone who knows how to correct this? Include or modify some files making this full crud work? Thanks a lot.

I guess you can avoid pickleForm problem if you edit your controller source code.

By default, it extends Controller, which, I guess, is wrong. Try to extend GController instead.

In yourapp/protected/controllers/FooController.php:


class FooController extends Controller

should became


class FooController extends GController

In the Full Crud Generator edit the Base Controller Class(at the very bottom) to be GController. I only had to do it once and it remembers. This solves most problems.

Any thoughts how we could implement a cool multi-language support for database tables.

A solution for the database schema is described here, but the FullCrud interface would be not looking so intuitive, I think.

EDIT: This is for version 0.4

Just posting to be able to post comments.

Great Extension.

Two issues:

  1. protected/components/Relation.php:549

Replace $_POST by $POSTs or anything else like:

public function handleAjaxRequest($_POSTsxxx) {

print_r($_POSTsxxx);

}

This solves a silly php error.

  1. protected/components/Relation.php:297

Replace ‘{id}’ => $obj->id); by ‘{id}’ => $obj->primaryKey);

This solves the ‘id’ not defined problem.

Chears!

If you step back and look at Gii from an overall project standpoint, a Gii Config template probably makes sense for defining project wide information that can be used by other templates. In that case, the Gii user could declare the languages used throughout the project in the config template and the CRUD template could use that information to generate message files.

Along the same lines, there is no reason why Gii could not use its own SqlLite database and DSN for storing project related information as well as other useful information (e.g., sets of form element options for every column data type supported by the various database engines which could allow a user to select the appropriate form element for each table column before CRUD generation begins). There are probably cases where individual templates might find it useful to store and recall information in temporary tables.

The language table mentioned in the solution does not necessarily need to exist but the applicable table columns do. A LanguageHelper could provide an array for populating language columns and the language column should be part of a composite primary key along with the table’s id column. If you wanted to add version control for something like CMS content articles or product descriptions, adding a ‘version’ column is also useful and should be part of the composite key (e.g., Rev B of a content article could exist along with Rev A in any given language).

If project related information for individual MVC triads (modules) is recorded as project completion proceeds, the information becomes useful for populating the various template fields and should minimize data entry.

Doing the above with Gii 1.x would take a bit of work, but the ActiveRecord in Gii 2 does an excellent job of handling composite keys, pivot tables, and relations in general.