예제 #1
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = '<div class="textarea_html_disabled"><pre>' . htmlspecialchars($this->value) . '</pre></div>';
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $output = Form::textarea($this->name, $this->value, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
예제 #2
0
 public function build()
 {
     $output = "";
     $this->attributes["class"] = "form-control";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             $output = Form::textarea($this->db_name, $this->value, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
예제 #3
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('redactor/jquery.browser.min.js');
             Rapyd::js('redactor/redactor.min.js');
             Rapyd::css('redactor/css/redactor.css');
             $output = Form::textarea($this->name, $this->value, $this->attributes);
             Rapyd::script("\$('#" . $this->name . "').redactor();");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
예제 #4
0
 public function build()
 {
     $output = "";
     $this->attributes["class"] = "form-control";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('packages/zofe/rapyd/assets/tinymce/tinymce.min.js');
             $output = Form::textarea($this->db_name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n          tinymce.init({\n            selector: 'textarea#" . $this->name . "',\n            plugins: [\n                 'advlist autolink link image lists charmap print preview hr anchor pagebreak',\n                 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n                 'save table contextmenu directionality emoticons template paste textcolor responsivefilemanager'\n            ],\n            toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons', \n            image_advtab: true ,\n            external_filemanager_path:'" . URL::to('/') . "/packages/filemanager/',\n            filemanager_title:'Upload',\n          });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
예제 #5
0
 /**
  * Make field HTML from field array
  *
  * @param  array  $field
  * @return string
  */
 private function makeField($field)
 {
     $output = '';
     //combine additional input attributes
     $input_attributes = array('class' => $field['input-class']);
     $input_attributes = array_merge($input_attributes, $field['input-attributes']);
     //
     //TEXT
     if ($field['type'] == "text") {
         $output .= Form::text($field['name'], $field['value'], $input_attributes);
     }
     //TEXTAREA
     if ($field['type'] == "textarea") {
         $output .= Form::textarea($field['name'], $field['value'], $input_attributes);
     }
     //PASSWORD
     if ($field['type'] == "password") {
         $output .= Form::password($field['name'], $field['value'], $input_attributes);
     }
     //SELECT
     if ($field['type'] == "select") {
         $output .= Form::select($field['name'], $field['options'], $field['value'], $input_attributes);
     }
     //CHECKBOXES
     if ($field['type'] == "checkbox") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="checkbox">';
             $checked = null;
             if (is_array($field['value']) && in_array($option_key, $field['value'])) {
                 $checked = true;
             }
             $output .= Form::checkbox($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //RADIO
     if ($field['type'] == "radio") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="radio">';
             $checked = false;
             if ($option_key == $field['value']) {
                 $checked = true;
             }
             $output .= Form::radio($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //FILE
     if ($field['type'] == "file") {
         $output .= Form::file($field['name'], $input_attributes);
     }
     //return
     return $output;
 }
예제 #6
0
<?php

use Illuminate\Support\Facades\Form;
Form::macro('textField', function ($name, $label = null, $value = null, $attributes = []) {
    $element = Form::text($name, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('passwordField', function ($name, $label = null, $attributes = []) {
    $element = Form::password($name, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('textareaField', function ($name, $label = null, $value = null, $attributes = []) {
    $element = Form::textarea($name, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('selectField', function ($name, $label = null, $options, $value = null, $attributes = []) {
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = []) {
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = []) {
    $attributes = array_merge(['id' => 'id-field-' . $name], $attributes);
    $out = '<div class="checkbox';
    $out .= fieldError($name) . '">';
    $out .= '<label>';
    $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label;
    $out .= '</div>';
예제 #7
0
파일: Formly.php 프로젝트: jonob/formly
 /**
  * Create a HTML textarea input element.
  *
  * @param string $name
  * @param string $label
  * @param null $value
  * @param array $attributes
  * @return string
  */
 public function textarea($name, $label = '', $value = null, $attributes = array())
 {
     $value = $this->calculateValue($name, $value);
     $attributes = $this->setAttributes($name, $attributes);
     if (!isset($attributes['rows'])) {
         $attributes['rows'] = 4;
     }
     $field = Form::textarea($name, $value, $attributes);
     return $this->buildWrapper($field, $name, $label);
 }