Skip to content

Instantly share code, notes, and snippets.

@havvg
Created February 16, 2011 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havvg/829802 to your computer and use it in GitHub Desktop.
Save havvg/829802 to your computer and use it in GitHub Desktop.
<?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()))));
}
}
}
}
}
@havvg
Copy link
Author

havvg commented Feb 16, 2011

This is an example use case for this enhancement in Propel ORM: http://www.propelorm.org/ticket/1274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment