예제 #1
0
 protected function _html()
 {
     if ($this->multiple) {
         $options = $this->getOptions();
         if ($this->sortable) {
             $checked_options = array();
             foreach ($this->value as $value) {
                 if (isset($options[$value])) {
                     $checked_options[$value] = $options[$value];
                 }
             }
             $options = $checked_options + array_diff_key($options, $checked_options);
         }
         $group = HTML::makeCheckboxGroup($this->input_name, $this->value, $options, '');
     } else {
         $group = HTML::makeRadioGroup($this->input_name, $this->value, $this->getOptions(), '');
     }
     if (!empty($this->disabled)) {
         foreach ($group->childs() as $child) {
             if ($child instanceof HTML && $child->tag == 'label') {
                 $input = $child->child(0);
                 if (in_array($input->value, $this->disabled)) {
                     $input->disabled = true;
                     if ($input->checked) {
                         $child->insert(HTML::makeInput('hidden', $input->name, $input->value)->id(null));
                     }
                 }
             }
         }
     }
     $group->addClass($this->getCSSClass(__CLASS__), $this->getCSSClass(__CLASS__, $this->style));
     if ($this->multiple && $this->sortable) {
         $group->addClass($this->getCSSClass(__CLASS__, 'sortable'));
     }
     return $group;
 }