예제 #1
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             $output = $this->value;
             $output = "<div class='help-block' style='background-color:" . $output . "'>&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::css('colorpicker/css/bootstrap-colorpicker.min.css');
             Rapyd::js('colorpicker/js/bootstrap-colorpicker.min.js');
             $output = Form::text($this->name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n                        \$('#" . $this->name . "').colorpicker({\n                            format: 'hex'\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
예제 #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::text($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
 /**
  * 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;
 }
예제 #4
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             if (!isset($this->value)) {
                 $value = $this->layout['null_label'];
             } else {
                 $value = $this->isoDateToHuman($this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->value != "") {
                 if (!$this->is_refill) {
                     $this->value = $this->isoDateToHuman($this->value);
                 }
             }
             Rapyd::css('datepicker/datepicker3.css');
             Rapyd::js('datepicker/bootstrap-datepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datepicker/locales/bootstrap-datepicker.' . $this->language . '.js');
             }
             unset($this->attributes['id']);
             //$this->attributes['class'] = "form-control";
             $from = Form::text($this->name . '[]', @$this->values[0], $this->attributes);
             $to = Form::text($this->name . '[]', @$this->values[1], $this->attributes);
             $output = '
                         <div id="range_' . $this->name . '_container">
                             <div class="input-daterange">
                                <div class="input-group">
                                    <div class="input-group-addon">&ge;</div>
                                    ' . $from . '
                                </div>
                                <div class="input-group">
                                     <div class="input-group-addon">&le;</div>
                                     ' . $to . '
                                </div>
                             </div>
                         </div>';
             Rapyd::pop_script();
             Rapyd::script("\n                        \$('#range_{$this->name}_container .input-daterange').datepicker({\n                            format: '{$this->formatToDate()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
예제 #5
0
    public function build()
    {
        $output = "";
        Rapyd::css('packages/zofe/rapyd/assets/autocomplete/autocomplete.css');
        Rapyd::js('packages/zofe/rapyd/assets/autocomplete/typeahead.bundle.min.js');
        Rapyd::js('packages/zofe/rapyd/assets/template/handlebars.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } elseif ($this->value == "") {
                    $output = "";
                } else {
                    $output = nl2br(htmlspecialchars($this->value));
                    if ($this->is_multiple) {
                        $output = '<div class="textarea_disabled">' . $output . '</div>';
                    }
                }
                break;
            case "create":
            case "modify":
                if (Input::get("auto_" . $this->db_name)) {
                    $autocomplete = Input::get("auto_" . $this->db_name);
                } elseif ($this->relation != null) {
                    $name = $this->rel_field;
                    $autocomplete = @$this->relation->get()->first()->{$name};
                } elseif (count($this->local_options)) {
                    $autocomplete = $this->description;
                } else {
                    $autocomplete = $this->value;
                }
                $output = Form::text("auto_" . $this->name, $autocomplete, array_merge($this->attributes, array('id' => "auto_" . $this->name))) . "\n";
                $output .= Form::hidden($this->name, $this->value, array('id' => $this->name));
                if ($this->remote) {
                    $script = <<<acp
    
                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('auto_{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: '{$this->remote}?q=%QUERY'
                    });
                    blod_{$this->name}.initialize();
                
                    \$('#div_{$this->name} .typeahead').typeahead(null, {
                        name: '{$this->name}',
                        displayKey: '{$this->record_label}',
                        highlight: true,
                        minLength: {$this->min_chars},
                        source: blod_{$this->name}.ttAdapter(),
                        templates: {
                            suggestion: Handlebars.compile('{{{$this->record_label}}}')
                        }
                    }).on("typeahead:selected typeahead:autocompleted", 
                        function(e,data) { \$('#{$this->name}').val(data.{$this->record_id});
                    });
acp;
                    $output .= Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};
                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();
                    
                    \$('#div_{$this->name} .typeahead').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).on("typeahead:selected typeahead:autocompleted", 
                        function(e,data) { 
                            \$('#{$this->name}').val(data.key);
                    });
acp;
                    $output .= Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }
예제 #6
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             if (!isset($this->value)) {
                 $value = $this->layout['null_label'];
             } else {
                 $value = $this->isodatetimeToHuman($this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->value != "") {
                 if (!$this->is_refill) {
                     $this->value = $this->isodatetimeToHuman($this->value);
                 }
             }
             Rapyd::css('datetimepicker/datetimepicker3.css');
             Rapyd::js('datetimepicker/bootstrap-datetimepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datetimepicker/locales/bootstrap-datetimepicker.' . $this->language . '.js');
             }
             $output = Form::text($this->name, $this->value, $this->attributes);
             Rapyd::script("\n                        \$('#" . $this->name . "').datetimepicker({\n                            format: '{$this->formatTodatetime()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
예제 #7
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>';
예제 #8
0
    public function build()
    {
        $output = "";
        //typeahead
        Rapyd::css('autocomplete/autocomplete.css');
        Rapyd::js('autocomplete/typeahead.bundle.min.js');
        Rapyd::js('template/handlebars.js');
        //tagsinput
        Rapyd::css('autocomplete/bootstrap-tagsinput.css');
        Rapyd::js('autocomplete/bootstrap-tagsinput.min.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } else {
                    $output = $this->description;
                }
                $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
                break;
            case "create":
            case "modify":
                $output = Form::text($this->name, '', array_merge($this->attributes, array('id' => "" . $this->name))) . "\n";
                if ($this->remote) {
                    $script = <<<acp

                    \$('#{$this->name}').tagsinput({
                      itemValue: '{$this->record_id}',
                      itemText: '{$this->record_label}'
                    });
                    {$this->fill_tags}

                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: '{$this->remote}?q=%QUERY'
                    });
                    blod_{$this->name}.initialize();

                    \$('#{$this->name}').tagsinput('input').typeahead(null, {
                        name: '{$this->name}',
                        displayKey: '{$this->record_label}',
                        highlight: true,
                        minLength: {$this->min_chars},
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));


acp;
                    Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};


                    \$('#{$this->name}').tagsinput({
                      itemValue: 'key',
                      itemText: 'value'
                    });
                    {$this->fill_tags}


                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();
                    \$('#{$this->name}').tagsinput('input').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));

acp;
                    Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }
예제 #9
0
파일: Formly.php 프로젝트: jonob/formly
 /**
  * Create a HTML text input element.
  *
  * @param string $name
  * @param string $label
  * @param null   $value
  * @param array  $attributes
  * @return string
  */
 public function text($name, $label = '', $value = null, $attributes = array())
 {
     $value = $this->calculateValue($name, $value);
     $attributes = $this->setAttributes($name, $attributes);
     $field = Form::text($name, $value, $attributes);
     return $this->buildWrapper($field, $name, $label);
 }