This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » No description for object of class ....
No description for object of class .... [message #86936] Mon, 19 October 2009 08:58 Go to next message
aupa  is currently offline 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 Go to previous messageGo to next message
aupa  is currently offline 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 Go to previous messageGo to next message
halfer  is currently offline 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 #86999 is a reply to message #86995 ] Tue, 20 October 2009 11:46 Go to previous messageGo to next message
aupa  is currently offline aupa
Messages: 11
Registered: October 2009
Junior Member
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...
Re: No description for object of class .... [message #87014 is a reply to message #86999 ] Tue, 20 October 2009 13:51 Go to previous messageGo to next message
mbernasocchi  is currently offline mbernasocchi
Messages: 31
Registered: June 2009
Member
hi, I had the same problem, and it turns out to happen when you try to echo an object that has no id, name, ... (as you already figured it out.
the solution is to do an echo $profil_id->getUsename (or whatever your field is called).

Hope it helps
Marco
Re: No description for object of class .... [message #87016 is a reply to message #87014 ] Tue, 20 October 2009 13:59 Go to previous messageGo to next message
aupa  is currently offline aupa
Messages: 11
Registered: October 2009
Junior Member
Thanks you for your help, but I don't understand where I have to do the echo ??
Re: No description for object of class .... [message #87027 is a reply to message #87016 ] Tue, 20 October 2009 15:28 Go to previous messageGo to next message
mbernasocchi  is currently offline mbernasocchi
Messages: 31
Registered: June 2009
Member
ok,
you need to check the newSuccess.php template of your user module. Probably (haven't tried) there is a <?php foreach ?> embedded in a <select> tag. there you should put your echo profil_id->getUsename

If it does not work post the newSuccess.php

ciao Marco
Re: No description for object of class .... [message #87584 is a reply to message #86999 ] Thu, 29 October 2009 20:26 Go to previous messageGo to next message
goshiz  is currently offline 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 Go to previous messageGo to next message
Bitcoder  is currently offline 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 Go to previous messageGo to next message
Bitcoder  is currently offline 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 #93318 is a reply to message #86936 ] Thu, 11 February 2010 10:48 Go to previous messageGo to next message
dedis  is currently offline dedis
Messages: 11
Registered: February 2010
Junior Member
Folowing the Practical Symfony DAY 03 Data Model :

http://www.symfony-project.org/jobeet/1_4/Doctrine/en/03#cha pter_03_see_it_in_action_in_the_browser

Quote:

If you try to edit a job, you will notice the Category id drop down has a list of all the category names. The value of each option is gotten from the __toString() method.

Doctrine will try and provide a base __toString() method by guessing a descriptive column name like, title, name, subject, etc. If you want something custom then you will need to add your own __toString() methods like below. The JobeetCategory model is able to guess the __toString() method by using the name column of the jobeet_category table.



I put that here because this post is well positioned on Google.
Re: No description for object of class .... [message #99477 is a reply to message #93318 ] Thu, 20 May 2010 17:00 Go to previous message
ederick  is currently offline 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
Previous Topic:sfWidgetFormInputFile doesn't redisplay the entered value after error
Next Topic:Symfony 1.2 - Display data from 3 tables using inner join
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software