/**
  * Overrides parent method end, adding Bootstrap styles to submit button.
  *
  * @param string|array $options as a string will use $options as the value of button,
  * @return string a closing FORM tag optional submit button.
  */
 public function end($options = null, $secureAttributes = array())
 {
     if ($options !== null) {
         if (!is_array($options)) {
             $options = array('label' => $options);
         }
         if (!isset($options['class'])) {
             $options['class'] = 'btn btn-default';
         }
     }
     return parent::end($options, $secureAttributes);
 }
Exemplo n.º 2
0
 public function input($fieldName, $options = array())
 {
     if (@$options['type'] == 'blueupload') {
         // TODO try to render the surrounding divs+classes from the $Bs3Form
         // so Bs3Form config is respected
         // construct the html NOW per partest
         // as without a dive into Bs3 the options do not cover the html I need now
         $label_options = $this->_initInputOptions($options);
         $label_options['label']['for'] = 'upload';
         $label = $this->_getLabel($fieldName, $label_options);
         //$label = $this->Html->tag('label', $options['label'], array('class'=>'col-sm-2 control-label', 'for'=>'files[]'));
         // render the input element
         $upload_config = Configure::read('BlueUpload.options.' . $options["upload_config"]);
         $options['type'] = 'file';
         $options['name'] = 'files[]';
         $options['multiple'] = true;
         $options['data-provide'] = 'fileupload';
         $options['data-url'] = Router::url($upload_config['script_url']);
         $options['label'] = false;
         $options['div'] = false;
         $input = $this->CakeForm->input($fieldName, $options);
         // render current values
         $template = $upload_config['edit_template'];
         $thumbnails = '';
         if (!empty($this->data['Upload'])) {
             $thumbnails = array_reduce($this->data['Upload'], function ($carry, $item) use($template) {
                 $carry .= $this->_View->Element($template, $item);
                 return $carry;
             });
         }
         $thumbnails = $this->Html->div('thumbnails sortables', $thumbnails);
         // add more button
         $plus = $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-plus'));
         //$button_label = $this->Html->tag('span', __("Select files..."));
         $button_label = $this->Html->tag('span', __("vybrat..."));
         $button = $this->Html->tag('span', $plus . ' ' . $button_label . $input, array('class' => 'btn btn-primary fileinput-button'));
         $element = $this->Html->div('col-sm-7 input-group', $button . $thumbnails);
         return $label . $element;
     } else {
         return parent::input($fieldName, $options);
     }
 }