Posted By

sorinspanu on 10/20/10


Tagged

form class list format radio


Versions (?)

Format Radio List in a Form Class


 / Published in: PHP
 

  1. <?php
  2. class GenreForm extends BaseGenreForm {
  3.  
  4. static public $decision = array(1 => 'Enable', 0 => 'Disable');
  5. public function getDecision() { return self::$decision; }
  6.  
  7. public function configure() {
  8. $this->widgetSchema['is_published'] = new sfWidgetFormSelectRadio(array(
  9. 'choices' => $this->getDecision(),
  10. 'formatter' => array($this, "formatRadioList")
  11. ));
  12. }
  13.  
  14. public function formatRadioList($widget, $inputs) {
  15. $rows = array();
  16. foreach ($inputs as $input) {
  17. $rows[] = $input['input'];
  18. }
  19.  
  20. $string = implode($this->getOption('separator'), $rows);
  21.  
  22. return $string;
  23. }
  24. }
  25. ?>

Report this snippet  

You need to login to post a comment.