Skip to content

Instantly share code, notes, and snippets.

@hugochinchilla
Created September 6, 2010 18:01
Show Gist options
  • Save hugochinchilla/567325 to your computer and use it in GitHub Desktop.
Save hugochinchilla/567325 to your computer and use it in GitHub Desktop.
<?php
public function configure()
{
$this->setWidget('hab_customer_location_list', $this->getHabLocationChoiceWidget());
}
protected function getHabLocationChoiceWidget()
{
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(HabLocationPeer::ID);
$c->addSelectColumn(HabLocationPeer::STATE);
$c->addSelectColumn(HabLocationPeer::CITY);
$c->addAscendingOrderByColumn(HabLocationPeer::STATE);
$c->addAscendingOrderByColumn(HabLocationPeer::CITY);
$stm = HabLocationPeer::doSelectStmt($c);
$locations = array();
while ($row = $stm->fetch(PDO::FETCH_ASSOC))
{
$locations[$row['ID']] = $row['STATE'].' - '.$row['CITY'];
}
return new sfWidgetFormChoice(array('choices' => $locations, 'multiple' => false));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment