Tuesday, October 26, 2010

generator.yml: Related Object's Fields in the DISPLAY List

If you want to show only the name (default field) of a related object, you can use the name of the object:

[id, name, Category]

This case Category will return with $this->getCategory()->getName() where $this is the current object. For other fields, create simple functions on the model class. Ex.:

// lib/model/doctrine/Article.class.php
public function getCategoryDescription()
{
  return $this->getCategory()->getDescription();
}


Now put this to the display list:

[id, name, category_description]

No comments:

Post a Comment