コード例 #1
0
ファイル: Form.php プロジェクト: swayok/html-tag-helper
 /**
  * @return string
  */
 public function buildSubmit()
 {
     if (!empty($this->submitButton)) {
         return $this->div(array('class' => 'submit'))->setContent($this->submitButton->build())->build();
     }
     return '';
 }
コード例 #2
0
ファイル: Radios.php プロジェクト: swayok/html-tag-helper
 /**
  * @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;
 }
コード例 #3
0
ファイル: Triggers.php プロジェクト: swayok/html-tag-helper
 /**
  * @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;
 }
コード例 #4
0
ファイル: Checkbox.php プロジェクト: swayok/html-tag-helper
 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();
 }
コード例 #5
0
ファイル: Image.php プロジェクト: swayok/html-tag-helper
 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();
 }
コード例 #6
0
ファイル: Hidden.php プロジェクト: swayok/html-tag-helper
 public function buildOpenTag()
 {
     $this->type = 'hidden';
     return parent::buildOpenTag();
 }
コード例 #7
0
ファイル: File.php プロジェクト: swayok/html-tag-helper
 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;
 }