Go to the documentation of this file.00001 <?php
00015 class axCheckboxGroupHelper extends axBaseHelper {
00016
00021 protected $_name;
00022
00027 protected static $_count = 1;
00028
00034 public function __construct ($name, array $values = array()) {
00035 parent::__construct('span');
00036 $this->_name = $name;
00037
00038 if (!empty($values))
00039 $this->addOptions($values);
00040 }
00041
00048 public function addOption ($label, $value) {
00049 $this->_children[] = axInputHelper::export($this->_name, 'checkbox', $value)->setId($id = 'checkbox' . (self::$_count ++));
00050 $this->_children[] = axLabelHelper::export($label, $id);
00051 return $this;
00052 }
00053
00060 public function addOptions (array $values) {
00061 foreach ($values as $key => $value)
00062 $this->addOption($key, $value);
00063 return $this;
00064 }
00065
00069 public function setValue ($value) {
00070 foreach ($this->_children as &$node) {
00071 if (($node instanceof axInputHelper) && $node->getValue() == $value) {
00072 $node->setChecked('checked');
00073 }
00074 }
00075
00076 return $this;
00077 }
00078
00083 public function getName () {
00084 return $this->_name;
00085 }
00086
00095 public static function export ($name, array $values = array()) {
00096 return new self ($name, $values);
00097 }
00098 }