Skip to content

Instantly share code, notes, and snippets.

@stajnert
Created August 23, 2012 11:00
Show Gist options
  • Save stajnert/3435545 to your computer and use it in GitHub Desktop.
Save stajnert/3435545 to your computer and use it in GitHub Desktop.
sfWidgetFormChoice formatter - every <li> put in new line
/**
* Metoda konfiguruje formularz
*/
public function configure()
{
$this->widgetSchema['cities'] = new sfWidgetFormChoice(array(
'expanded' => true,
'multiple' => true,
'choices' => Doctrine_Core::getTable('hall')->getListNameForOpenHall(),
'renderer_options' => array('formatter' => array($this, 'formatter'))
));
}
/**
* Metoda formatuje obiekt sfWidgetFormChoice - dzieli elementy <li> listy
* tak by kazdy znalazl sie w nowej linii
*
* @param sfWidget $widget
* @param array $inputs
* @return string
*/
public function formatter($widget, $inputs)
{
$rows = array();
$separator = '<br />';
foreach ($inputs as $i => $input) {
$rows[] = $widget->renderContentTag(
'li', $input['input'] . ' ' . $input['label'], ($i % 2 > 0 ? array('class' => 'pair') : array('class' => 'impair'))
);
}
return $widget->renderContentTag('ul', implode($separator, $rows), array('class' => 'radio_list'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment