Axiom (v1.2.0)

A lightweight PHP framework
H:/Workspace/php-axiom/www/php-axiom/libraries/axiom/axRadioGroupHelper.class.php
Go to the documentation of this file.
00001 <?php
00016 class axRadioGroupHelper extends axBaseHelper {
00017 
00022     protected $_name;
00023 
00029     protected static $_count = 1;
00030 
00039     public function __construct ($name, $values = array()) {
00040         parent::__construct('span');
00041         $this->_name = $name;
00042 
00043         if (!empty($values))
00044             $this->addOptions($values);
00045     }
00046 
00053     public function addOption ($label, $value) {
00054         $this->_children[] = axInputHelper::export($this->_name,'radio',$value)->setId($id='radio'.(self::$_count ++));
00055         $this->_children[] = axLabelHelper::export($label, $id);
00056         return $this;
00057     }
00058 
00082     public function addOptions (array $values) {
00083         foreach ($values as $key => $value)
00084             $this->addOption($key, $value);
00085         return $this;
00086     }
00087 
00091     public function setValue ($value) {
00092         foreach ($this->_children as &$node) {
00093             if (($node instanceof axInputHelper) && $node->getValue() == $value) {
00094                 $node->setChecked('checked');
00095             }
00096         }
00097 
00098         return $this;
00099     }
00100     
00105     public function getName () {
00106         return $this->_name;
00107     }
00108 
00115     public static function export ($name, $values = array()) {
00116         return new self ($name, $values);
00117     }
00118 }
 All Data Structures Files Functions Variables