コード例 #1
0
ファイル: html_form.php プロジェクト: 2626suke/curryfw
 /**
  * Create and return element of input tags whose type are checkbox
  * 
  * @param string $name
  * @param array $list
  * @param string $defaultValue
  * @param array $attributes
  * @return FormElementSet
  */
 public function createCheckboxes($name = null, $list = array(), $defaultValue = null, $attributes = null)
 {
     $this->_checkArgumentIsArray(__METHOD__, 2, $list);
     $frame = $this->createFormElementSet('span');
     if (!is_array($attributes)) {
         $attributes = array();
     }
     $attributes['type'] = 'checkbox';
     if (is_array($list)) {
         foreach ($list as $value => $text) {
             $checkbox = new FormElement('input');
             $checkbox->setIsReturnInner(false);
             $checkbox->setAttributes($attributes);
             $checkbox->setValue($value);
             $label = new HtmlElement('label');
             $label->setIsReturnInner(false);
             $label->addElement($checkbox);
             $label->addNode($text);
             $frame->addElement($label);
         }
     }
     $frame->setName($name);
     if ($defaultValue !== null) {
         $frame->setValue($defaultValue);
     }
     return $frame;
 }