| No description for object of class .... [message #86936] |
Mon, 19 October 2009 08:58  |
aupa Messages: 11 Registered: October 2009 |
Junior Member |
|
|
Hi,
environment : symfony 1.2, doctrine, mysql
I have generated two modules (profils et users) by using this command : php symfony doctrine:generate-admin backend User user.
There is a relationship 1:n between the two modules. One user is attached to one profil and one profil can belong to several users.
The problem is, when I go to the user module (http://localhost/backend_dev.php/user) to create a new user, there is a problem in my dropdownlist profil_id (profil_id which is the foreign key to the profil table). Inside my dropdownlist, instead of having the values contains in my database (administrator for example),I have this message : "No description for object of class Profil".
It's like my foreign key (profil_id) is not recognized by the user module...
I don't know what I have to do to solve this problem...
Thanks,
|
|
|
| Re: No description for object of class .... [message #86987 is a reply to message #86936 ] |
Tue, 20 October 2009 09:32   |
aupa Messages: 11 Registered: October 2009 |
Junior Member |
|
|
I have succeeded in solving the problem. I had to modify the __toString() function located in lib\plugins\sfDoctrinePlugin\lib\record\sfDoctrineRecord.cla ss.php.
The array defined below
$guesses = array('name',
'title',
'description',
'subject',
'keywords',
'id')
tries to guess the name corresponding to an id field.
In my case, the names definied in the array don't match with the name which I give (user_lib for example).
I change this for :
$guesses = array('name',
'title',
'description',
'subject',
'keywords',
'id', substr($this->getTable()->getTableName(), 0, 3).'_lib');
And it works !
|
|
|
| Re: No description for object of class .... [message #86995 is a reply to message #86936 ] |
Tue, 20 October 2009 11:27   |
halfer Messages: 9535 Registered: January 2006 Location: West Midlands, UK |
Faithful Member |
|
|
I don't use Doctrine, but I am pretty certain this is not the right solution. Modifying plugin code directly should almost never be required, though there are sometimes some edge-cases where it may be necessary. But I would guess Doctrine creates classes that extend sfDoctrineRecord, which you can modify?
Read the docs here, they're very good:
http://www.doctrine-project.org/documentation
Remember Palestine
|
|
|
|
|
|
|
| Re: No description for object of class .... [message #87584 is a reply to message #86999 ] |
Thu, 29 October 2009 20:26   |
goshiz Messages: 4 Registered: October 2009 |
Junior Member |
|
|
| aupa wrote on Tue, 20 October 2009 11:46 | Maybe you're right but I haven't seen any class that extend sfDoctrineRecord...I will continue to search.
I don't like this solution but it's the only one I found..
I could have renamed my column to 'id' without modifying the class of the framework, but I also want to name my column as I like...
|
sfDoctrineRecord extended into class BaseMyClass (file : /lib/model/doctrine/base/BasMyClass.class.php)
And class BaseMyClass is extended into class MyClass (file : /lib/model/doctrine/MyClass.class.php)
So, you just need to copy __toString, and make your changes in /lib/model/doctrine/MyClass.class.php
And voila !
[Updated on: Thu, 29 October 2009 20:26]
|
|
|
| Re: No description for object of class .... [message #90714 is a reply to message #87584 ] |
Thu, 31 December 2009 21:57   |
Bitcoder Messages: 15 Registered: December 2009 Location: Quito |
Junior Member |
|
|
I have same problem but in my case I use a different name for each table description field. For example, uio_name, air_name, etc. Also three first table name characters do not represent first part of description field.
¿Is there another way to get this working?
Best Regards,
Guillermo Garcia
|
|
|
| Re: No description for object of class .... [message #90746 is a reply to message #87584 ] |
Sat, 02 January 2010 20:11   |
Bitcoder Messages: 15 Registered: December 2009 Location: Quito |
Junior Member |
|
|
| goshiz wrote on Thu, 29 October 2009 14:26 |
| aupa wrote on Tue, 20 October 2009 11:46 | Maybe you're right but I haven't seen any class that extend sfDoctrineRecord...I will continue to search.
I don't like this solution but it's the only one I found..
I could have renamed my column to 'id' without modifying the class of the framework, but I also want to name my column as I like...
|
sfDoctrineRecord extended into class BaseMyClass (file : /lib/model/doctrine/base/BasMyClass.class.php)
And class BaseMyClass is extended into class MyClass (file : /lib/model/doctrine/MyClass.class.php)
So, you just need to copy __toString, and make your changes in /lib/model/doctrine/MyClass.class.php
And voila !
|
Finally, I got working!. Using Polymorphism with __toString Method into /lib/model/doctrine/MyClass.class.php like this:
public function __toString()
{
$descriptionColumn = 'description_name';
try
{
return (string) $this->get($descriptionColumn);
}
catch (Exception $e)
{
return sprintf('Can't show "%s"', $this->getTable()->getComponentName());
}
}
Best Regards
Guillermo Garcia
|
|
|
|
| Re: No description for object of class .... [message #99477 is a reply to message #93318 ] |
Thu, 20 May 2010 17:00  |
ederick Messages: 1 Registered: May 2010 Location: Venezuela |
Junior Member |
|
|
Thank you for posting the official solution. I solved exactly as they explain in the Practical Symfony | Day 3 Document
I am using Symfony 1.4
Here is my solution:
//..lib/model/doctrine/Privilegios.class.php
class Privilegios extends BasePrivilegios
{
public function __toString()
{
return sprintf('%s -> %s (%s)', $this->getPkPrivilegios(), $this->getNombre(), $this->getDescripcion());
}
}
//..lib/model/doctrine/Grupo.class.php
class Grupo extends BaseGrupo
{
public function __toString()
{
return $this->getNombre();
}
}
ederick.colmenares
|
|
|