Created
August 23, 2012 11:00
-
-
Save stajnert/3435545 to your computer and use it in GitHub Desktop.
sfWidgetFormChoice formatter - every <li> put in new line
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
/** | |
* 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