Exemplo n.º 1
0
 /**
  * @return string
  */
 public function buildSubmit()
 {
     if (!empty($this->submitButton)) {
         return $this->div(array('class' => 'submit'))->setContent($this->submitButton->build())->build();
     }
     return '';
 }
Exemplo n.º 2
0
 /**
  * @return array
  */
 public function createInputs()
 {
     $radios = array();
     if ($this->options) {
         $index = 1;
         foreach ($this->options as $value => $label) {
             $id = $this->id . $index;
             $index++;
             $radio = new FormInput($this->form, $this->name, array('type' => 'radio', 'value' => $value, 'multiple' => true, 'id' => $id));
             $label = new Label(array('content' => $label, 'for' => $id));
             $this->inputs[] = array($radio, $label);
             if (isset($this->attributes['value']) && self::compareValues($this->attributes['value'], $value)) {
                 $radio->setChecked(true);
             }
             $radios[] = array('label' => $label, 'input' => $radio);
         }
     }
     return $radios;
 }
Exemplo n.º 3
0
 /**
  * @return array
  */
 public function createInputs()
 {
     $triggers = array();
     if ($this->options) {
         $index = 1;
         $defaultAttributes = array_intersect_key($this->attributes, array_flip($this->passAttributes));
         foreach ($this->options as $value => $label) {
             $id = $this->id . $index;
             $index++;
             $localAttributes = array_merge($defaultAttributes, array('type' => $this->multiple ? 'checkbox' : 'radio', 'value' => $value, 'label' => $label, 'class' => 'trigger-button', 'multiple' => $this->multiple, 'id' => $id));
             $trigger = new FormInput($this->form, $this->name, $localAttributes);
             $label = new Label(array('content' => $label, 'for' => $id));
             $this->triggers[] = array($trigger, $label);
             if (isset($this->attributes['value']) && self::compareValues($this->attributes['value'], $value)) {
                 $trigger->setChecked(true);
             }
             $triggers[] = array('label' => $label, 'input' => $trigger);
         }
     }
     return $triggers;
 }
Exemplo n.º 4
0
 public function buildOpenTag()
 {
     $attributes['type'] = 'checkbox';
     $this->attributes['value'] = $this->valueIfChecked;
     if (!isset($this->attributes['checked'])) {
         $this->checked = $this->form->getInputValue($this->name) ? true : false;
     }
     if ($this->hiddenInput) {
         $hiddenInput = new Hidden($this->form, $this->name, array('value' => '0', 'id' => $this->id . '_hidden'));
     } else {
         $hiddenInput = '';
     }
     return $hiddenInput . parent::buildOpenTag();
 }
Exemplo n.º 5
0
 public function buildCloseTag()
 {
     $previewBlock = '';
     if ($this->hasFileUploaded()) {
         $filesToShow = array_intersect_key($this->files, array_flip($this->preview));
         if (!empty($filesToShow)) {
             foreach ($filesToShow as $version => $url) {
                 if (array_key_exists($version . '_path', $this->files) && (empty($this->files[$version . '_path']) || !file_exists($this->files[$version . '_path']))) {
                     unset($filesToShow[$version]);
                 }
             }
         }
         $previewBlock = !empty($filesToShow) ? ImagePreview::create()->setContent($filesToShow) : '';
     }
     return $previewBlock . parent::buildCloseTag();
 }
Exemplo n.º 6
0
 public function buildOpenTag()
 {
     $this->type = 'hidden';
     return parent::buildOpenTag();
 }
Exemplo n.º 7
0
 public function buildCloseTag()
 {
     $closeTag = parent::buildCloseTag();
     $fileName = empty($this->value) ? '' : $this->div(preg_replace('%^.*/(.*)$%', '$1', $this->value))->setClass('form-input-current-file-name');
     return $closeTag . $fileName;
 }