Ejemplo n.º 1
0
 /**
  * @return Element
  */
 protected function buildBoolean()
 {
     $value = strlen($this->value) ? $this->value ? 1 : 0 : ($this->null ? null : 0);
     if ($this->null) {
         $input = new Select($this->getFieldName(), ['' => '', '0' => 'no', '1' => 'yes'], $value);
         if ($this->readonly) {
             $input->setAttribute('readonly');
         }
         return $input;
     } else {
         $input = new Input($this->getFieldName());
         $input->setAttribute('type', 'hidden');
         $input->setAttribute('value', $value);
         $checkbox = new Input();
         $checkbox->setAttribute('type', 'checkbox');
         $checkbox->setAttribute('value', $value);
         if ($this->value) {
             $checkbox->setAttribute('checked');
         }
         if ($this->readonly) {
             $checkbox->setAttribute('readonly');
         }
         if ($this->null) {
             $checkbox->setData('nullable', strlen($this->value) ? $this->value ? 0 : 1 : 0);
         }
         return $input . $checkbox;
     }
 }