Symfony sfException Call to undefined method BaseModel::__toString

Working on some projects in Symfony recently. I ran into a problem when I used the symfony admin generator to create a "backend" module for a table that has a foreign key relationship.

Symfony was looking for me to have a __toString() function in my model so it could create the drop down menu. So for instance, let's say you have tables like countries and states in your schema.xml. Country_id in the states table is a foreign key to the Countries table like so:


When you do:
symfony propel-init-admin backend states States
Symfony is going to create the edit and create actions of the States screens with a drop-down menu of countries that the state is a part of. The value of the country drop down is the country_id. the value needs to be set in a __toString() function in your Country propel model. The easiest thing is to just return a simple string name (if that's in your db model):


function __toString()
return $this->name;

That should solve the problem. It's odd that this comes up. And I couldn't find anything on it when googling.


Drupal 6 and new Apress Drupal book

I have been working on a couple of projects using Drupal lately that required creating some custom modules. So again, I flipped thru my well-worn copy of Pro Drupal Development. Here is my earlier review of Pro Drupal Development.

Drupal has released version 6 now. So I click to the Apress site and lo and behold, they're already working on Pro Drupal Development, 2nd edition which will feature updates for Drupal 6. If it is as good as the first book, it will be a must have for any Drupal developer.