コード例 #1
0
 /**
  * constructor
  *
  * @param string $elementName (optional) name of the checkbox
  * @param string $elementLabel (optional) checkbox label
  * @param string $text (optional) Text to put after the checkbox
  * @param mixed $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  * @param mixed $values (optional) Values to pass if checked or not checked
  */
 public function __construct($elementName = null, $elementLabel = null, $text = null, $attributes = null, $values = null)
 {
     if ($values === null) {
         $values = array(0, 1);
     }
     if (!is_null($attributes['group'])) {
         $this->_group = 'checkboxgroup' . $attributes['group'];
         unset($attributes['group']);
         if (is_null($attributes)) {
             $attributes = array();
             $attributes['class'] .= " {$this->_group}";
         } elseif (is_array($attributes)) {
             if (isset($attributes['class'])) {
                 $attributes['class'] .= " {$this->_group}";
             } else {
                 $attributes['class'] = $this->_group;
             }
         } elseif ($strpos = stripos($attributes, 'class="')) {
             $attributes = str_ireplace('class="', 'class="' . $this->_group . ' ', $attributes);
         } else {
             $attributes .= ' class="' . $this->_group . '"';
         }
     }
     parent::__construct($elementName, $elementLabel, $text, $attributes, $values);
 }