Created
February 16, 2011 17:47
-
-
Save havvg/829802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class BaseFormFilterPropel extends sfFormFilterPropel | |
{ | |
public function setup() | |
{ | |
parent::setup(); | |
foreach ($this->getFields() as $eachFieldName => $eachFieldType) | |
{ | |
if ($eachFieldType == 'ForeignKey') | |
{ | |
/* @var $widget sfWidgetForm */ | |
$widget = $this->getWidget($eachFieldName); | |
$model = $widget->getOption('model'); | |
$peer = $model::PEER; | |
$tmClass = $peer::TM_CLASS; | |
/* @var $tableMap TableMap */ | |
$tableMap = new $tmClass; | |
if ($tableMap->hasPrimaryStringColumn()) | |
{ | |
$widget->setOption('query_methods', array_merge($widget->getOption('query_methods'), array('orderBy' . ucfirst($tableMap->getPrimaryStringColumn()->getPhpName())))); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example use case for this enhancement in Propel ORM: http://www.propelorm.org/ticket/1274