Example #1
3
 /**
  * @return string
  */
 public function run()
 {
     $this->registerClientScript();
     $options = ArrayHelper::merge($this->options, ['class' => 'form-control']);
     if ($this->format) {
         $options['data-date-format'] = $this->format;
     }
     return $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $options) : Html::textInput($this->name, $this->value, $options);
 }
    /**
     * Runs the widget.
     */
    public function run()
    {
        // Print elfinder widget in modal
        Modal::begin(['toggleButton' => false, 'id' => $this->options['id'] . '-dialog', 'size' => Modal::SIZE_LARGE]);
        echo ElFinder::widget(['language' => $this->language, 'controller' => $this->controller, 'path' => $this->path, 'filter' => 'image', 'callbackFunction' => new JsExpression('function(file, id){

                console.log( file.url, "' . $this->buttonOptions['id'] . '" );

                $("#' . $this->options['id'] . '").val( file.url );
                $("#' . $this->options['id'] . '-thumb").attr("src", file.url ).show();
                $("#' . $this->options['id'] . '-dialog").modal("hide");

            }'), 'path' => $this->path, 'frameOptions' => ['style' => 'width: 100%; height: 500px; border: 0px;']]);
        Modal::end();
        // Render input and upload button
        if ($this->hasModel()) {
            $attr = $this->attribute;
            $hidden = $this->model->{$attr} ? '' : 'display:none;';
            $replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" class="thumbnail" src="' . $this->model->{$attr} . '" style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
            $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
        } else {
            $hidden = $this->value ? '' : 'display:none;';
            $replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" src="' . $this->value . '"  style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
            $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
        }
        $replace['{button}'] = Html::tag($this->buttonTag, $this->buttonName, $this->buttonOptions);
        echo strtr($this->template, $replace);
        // Publish assets
        AssetsCallBack::register($this->getView());
        if (!empty($this->multiple)) {
            $this->getView()->registerJs("\n\n            mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ",\n                function(files, id){\n                    var _f = [];\n                    for (var i in files) { _f.push(files[i].url); }\n                    \$('#' + id).val(_f.join(', ')).trigger('change');\n                    return true;\n                });\n\n            \$(document).on('click','#" . $this->buttonOptions['id'] . "',\n                function(){\n                    mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n                }\n            );");
        } else {
            $this->getView()->registerJs("\n\n                mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n                    \$('#' + id).val(file.url).trigger('change');\n                    return true;\n                });\n\n                \$(document).on('click',\n                    '#" . $this->buttonOptions['id'] . "',\n                    function(){\n                        //mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n                        \$('#" . $this->options['id'] . "-dialog').modal('show');\n                    }\n                );");
        }
    }
Example #3
1
 /**
  * @throws \yii\base\InvalidConfigException
  */
 protected function initOptions()
 {
     $this->{$this->buttonPlace} = Html::tag('span', $this->sortButtonName, ['class' => 'grid-sort-button ' . $this->buttonClass]);
     $this->format = 'raw';
     $this->value = function ($model, $key, $index, $widget) {
         return Html::textInput($this->attribute . "[{$model->id}]", $model->{$this->attribute}, ['style' => 'width:40px; text-align:center', 'class' => 'grid-sort-input ' . $this->inputClass]);
     };
 }
 public function getFormAttribs()
 {
     return ['customer' => ['type' => TabularForm::INPUT_HIDDEN, 'columnOptions' => ['hidden' => true]], 'name' => ['type' => TabularForm::INPUT_STATIC], 'measurement_type' => ['type' => TabularForm::INPUT_STATIC, 'value' => function ($m, $k, $i, $w) {
         return MaterialTypes::$measurementType[$m->measurement_type];
     }], 'price' => ['type' => TabularForm::INPUT_RAW, 'value' => function ($m, $k, $i, $w) {
         return Html::textInput("price[" . $k . "]", CustomerMaterialPrice::getPrice($k, $this->customer), ['class' => 'form-control']);
     }]];
 }
Example #5
0
 private function renderTextInput()
 {
     if ($this->state() !== self::STATE_TEXT) {
         Html::addCssStyle($this->textInputOptions, 'display:none');
     }
     return Html::textInput(null, $this->inputValue(self::STATE_TEXT), $this->textInputOptions);
 }
 public function run()
 {
     $content = [];
     if ($this->showAddon) {
         Html::addCssClass($this->containerOptions, 'input-group');
     }
     if ($this->containerTag) {
         $content[] = Html::beginTag($this->containerTag, $this->containerOptions);
     }
     if ($this->hasModel()) {
         if ($this->autoPlaceholder && !$this->options['placeholder']) {
             $this->options['placeholder'] = $this->model->getAttributeLabel($this->attribute);
         }
         $content[] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $content[] = Html::textInput($this->name, $this->value, $this->options);
     }
     if ($this->showAddon) {
         $content[] = $this->renderInputAddon();
     }
     if ($this->containerTag) {
         $content[] = Html::endTag($this->containerTag);
     }
     return implode("\n", $content);
 }
Example #7
0
 public function run()
 {
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     }
     return Html::textInput($this->name, $this->value, $this->options);
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $inputId = $this->options['id'];
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = array_merge($this->options, ['value' => $value]);
     if ($hasModel) {
         $output = Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $output = Html::textInput($this->name, $this->value, $options);
     }
     if (!is_null($this->alias)) {
         $clientOptions = array_merge($this->clientOptions, ['alias' => $this->alias]);
     } else {
         $clientOptions = array_merge($this->clientOptions, ['mask' => $this->mask]);
     }
     if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
         $clientOptions['placeholder'] = $options['placeholder'];
     }
     $js = 'jQuery(\'#' . $inputId . '\').inputmask(' . Json::htmlEncode($clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         InputMaskAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
Example #9
0
 public function run()
 {
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
     }
     $replace['{button}'] = Html::button($this->buttonName, $this->buttonOptions);
     $replace['{preview}'] = Html::a($this->previewButtonName, "#" . $this->previewButtonOptions['id'] . '_popup', $this->previewButtonOptions) . '
         <div id="' . $this->previewButtonOptions['id'] . '_popup" class="modal fade" tabindex="-1" role="dialog">
             <div class="modal-dialog">
                 <div class="modal-content">
                     <div class="modal-header">
                         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                         <h5 class="modal-title"><i class="fa fa-picture-o"></i> Preview</h5>
                     </div>
                     <div class="modal-body has-padding">
                         <img width="100%" src="' . $this->suffix . $this->model->{$this->attribute} . '">
                     </div>
                     <div class="modal-footer">
                         <button class="btn btn-warning" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
                     </div>
                 </div>
             </div>
         </div>';
     echo strtr($this->template, $replace);
     AssetsCallBack::register($this->getView());
     if (!empty($this->multiple)) {
         $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(files, id){ var _f = []; for (var i in files) { _f.push(files[i].url); } \$('#' + id).val(_f.join(', ')); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
     } else {
         $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\r\n\t \$('#' + id).val(file.url.replace('" . $this->suffix . "', ''));\r\n\t \$('#' + id + '_preview_popup .modal-body').html('<img width=\"100%\" src=\"' + file.url + '\">'); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
     }
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $view = $this->getView();
     $kcfinder = KCFinderAsset::register($view);
     if ($this->hasModel()) {
         if (!empty($this->model->icon)) {
             $this->src = $this->model->icon;
         }
     }
     //$this->options = array_merge($this->options, ['onclick'=>'openKCFinder(this);']);
     echo Html::tag('div', Html::img($this->src, ['id' => $this->widget['id'] . '-preview', 'class' => 'img-responsive']), ['class' => 'well well-sm text-center', 'style' => 'margin:5px;']);
     echo '<div class="input-group">';
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-clear"><i class="glyphicon glyphicon-remove"></i></button></span>';
     echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-browse"><i class="glyphicon glyphicon-folder-open"></i></button></span>';
     echo '</div>';
     $session = Yii::$app->session;
     if (!$session->has('KCFINDER')) {
         $session->set('KCFINDER', ['disabled' => false, 'uploadDir' => $this->uploadDir, 'uploadURL' => $this->uploadURL]);
         $htSource = __DIR__ . '/upload.htaccess';
         $htDest = $kcfinder->basePath . '/conf/upload.htaccess';
         copy($htSource, $htDest);
     }
     $this->registerJs();
 }
Example #11
0
 private function renderFields()
 {
     $rows = '';
     if (count($this->_config['fieldName'])) {
         foreach ($this->_config['fieldName'] as $ind => $n) {
             $search = [];
             $replace = [];
             $t = $this->_config['fieldType'][$ind];
             $r = $this->_config['fieldRequired'][$ind];
             //$opt = $r ? ['required'=>true] : [];
             $name = 'f' . $ind;
             $label = Html::label($n) . ($r ? $this->_config['tplMarker'] : '');
             $search[] = '{*label*}';
             $replace[] = $label;
             if ($t == 'input') {
                 $opt['maxlength'] = 50;
                 $tpl = 'tplInput';
                 $field = Html::textInput($name, null, $opt);
             } elseif ($t == 'textarea') {
                 $opt['rows'] = 4;
                 $opt['maxlength'] = 500;
                 $tpl = 'tplArea';
                 $field = Html::textarea($name, '', $opt);
             }
             if (strpos($this->_config[$tpl], '{*label*}') === false && $r) {
                 $field .= $this->_config['tplMarker'];
             }
             $search[] = '{*field*}';
             $replace[] = $field;
             $rows .= str_replace($search, $replace, $this->_config[$tpl]) . "\n";
         }
     }
     return $rows;
 }
Example #12
0
 /**
  * Render input for formatted value
  */
 protected function renderInput()
 {
     //Html::addCssClass($this->_inputOptions, 'form-control');
     $this->addDataOptions();
     $input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
     return $input;
 }
Example #13
0
 public function init()
 {
     parent::init();
     $this->_inputStr = '<div class="form-group">';
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
     } else {
         $this->_inputStr .= Html::label($this->name);
     }
     $this->_inputStr .= '<div id="' . Html::encode($this->name) . '" class="input-group date">';
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     if ($value !== null) {
         $value = Yii::$app->formatter->asDatetime($value);
     }
     $options = $this->options;
     $options['class'] = 'form-control';
     //$options['readonly'] = '';
     $options['value'] = $value;
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $this->_inputStr .= Html::textInput($this->name, $this->value, $options);
     }
     $this->_inputStr .= '<span class="input-group-addon">
                                     <span class="glyphicon-calendar glyphicon"></span>
                                 </span>
                             </div>
                             </div>
                             ';
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (empty($this->data) || !is_array($this->data)) {
         throw new InvalidConfigException("You must define the 'data' property");
     }
     $this->registerAssets();
     echo Html::tag('div', Html::textInput($this->name, $this->value, $this->options), $this->container);
 }
Example #15
0
 /**
  * Renders the Spinner widget.
  * @return string the rendering result.
  */
 public function renderWidget()
 {
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         return Html::textInput($this->name, $this->value, $this->options);
     }
 }
Example #16
0
 /**
  * Renders a text input for widget display along with an internal
  * hidden input to validate and save the raw number (float) data.
  */
 protected function renderInput()
 {
     $name = $this->_displayOptions['id'];
     Html::addCssClass($this->_displayOptions, 'form-control');
     $input = Html::textInput($name, $this->value, $this->_displayOptions);
     $input .= $this->hasModel() ? Html::activeHiddenInput($this->model, $this->attribute, $this->options) : Html::hiddenInput($this->name, $this->value, $this->options);
     echo $input;
 }
Example #17
0
 /**
  * Rendering field input of date range picker.
  * @return string
  */
 protected function renderFieldInput()
 {
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         return Html::textInput($this->name, $this->value, $this->options);
     }
 }
 /**
  * Runs the widget.
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     $this->registerClientScript();
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $view = $this->getView();
     PlacesPluginAsset::register($view);
     $this->varName = "addressPicker" . static::$widgetCounter++;
     $script = implode("\n", [$this->buildAdapter(), $this->buildTypeAhead(), $this->buildEvent()]);
     $view->registerJs($script);
     return $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
 }
Example #20
0
 /**
  * Runs the widget
  *
  * @return string|void
  */
 public function run()
 {
     $this->registerAssets();
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
 }
 public function run()
 {
     $form = \yii\widgets\ActiveForm::begin(['id' => 'simple-search-form', 'action' => [$this->options['action']], 'enableAjaxValidation' => false]);
     echo Html::textInput('search', null, ['class' => 'form-control', 'hint' => YBoard::t('yboard', 'Search')]);
     echo Html::hiddenInput('type', '0');
     echo Html::hiddenInput('choice', '0');
     Html::submitButton('Submit', ['class' => 'small-search-button']);
     \yii\widgets\ActiveForm::end();
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!$this->readOnly) {
         echo $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
     } else {
         echo Html::tag('span', '', $this->options);
     }
     $this->registerPlugin('bfhphone');
 }
Example #23
0
 protected function honeypot()
 {
     $field = Html::beginTag('div', ['class' => '', 'style' => 'display:none']);
     $field .= Html::label(Yii::t('app', 'Excuse me, but leave this field in blank'), "_email", ['class' => 'control-label']);
     $field .= Html::textInput("_email", null, ['id' => '_email', 'class' => 'form-control']);
     $field .= Html::endTag('div') . ' ';
     $field .= Html::endForm();
     return $field;
 }
Example #24
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     parent::run();
 }
Example #25
0
 public function run()
 {
     $this->registerPlugin('intlTelInput');
     if ($this->hasModel()) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         return Html::textInput($this->name, $this->value, $this->options);
     }
 }
Example #26
0
 public function run()
 {
     echo '
         <div class="input-group date" id="' . $this->widgetId . '">
             ' . Html::textInput('', '', ['class' => 'form-control']) . '
             ' . Html::activeHiddenInput($this->model, $this->attribute) . '
             <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
         </div>
     ';
 }
Example #27
0
 /**
  * @inheritdoc
  */
 public function renderHtml()
 {
     if ($this->form !== null && $this->model !== null) {
         return $this->form->field($this->model, $this->attribute)->hint($this->hint)->textInput($this->options);
     }
     if ($this->model !== null) {
         return Html::activeTextInput($this->model, $this->attribute, $this->options);
     }
     return Html::textInput($this->name, $this->value, $this->options);
 }
 protected function renderWidget()
 {
     $contents = [];
     // get formatted date value
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = $this->options;
     $options['value'] = $value;
     if ($this->inline === false) {
         // render a text input
         if ($this->hasModel()) {
             $contents[] = Html::activeTextInput($this->model, $this->attribute, $options);
         } else {
             $contents[] = Html::textInput($this->name, $value, $options);
         }
     } else {
         // render an inline date picker with hidden input
         if ($this->hasModel()) {
             $contents[] = Html::activeHiddenInput($this->model, $this->attribute, $options);
         } else {
             $contents[] = Html::hiddenInput($this->name, $value, $options);
         }
         $this->clientOptions['defaultDate'] = $value;
         $this->clientOptions['altField'] = '#' . $this->options['id'];
         $contents[] = Html::tag('div', null, $this->containerOptions);
     }
     return implode("\n", $contents);
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     // Generate an selector which will be used by jQuery
     if (isset($this->options['id'])) {
         $this->_selector = '#' . $this->options['id'];
     } elseif (!isset($this->options['data-tokenfield-id'])) {
         $id = uniqid('tokenfield_');
         $this->options['data-tokenfield-id'] = $id;
         $this->_selector = "[data-tokenfield-id={$id}]";
     }
     // Input
     if ($this->hasModel()) {
         // If overwriting the model value
         if ($this->overwriteValue && $this->value) {
             $name = Html::getInputName($this->model, $this->attribute);
             $val = is_array($this->value) ? implode(', ', $this->value) : $this->value;
             echo Html::textInput($name, $val, $this->options);
             // If normal model
         } else {
             echo Html::activeTextInput($this->model, $this->attribute, $this->options);
         }
         // Not active record
     } else {
         $val = is_array($this->value) ? implode(', ', $this->value) : $this->value;
         echo Html::textInput($this->name, $val, $this->options);
     }
     // Register the bootstrap-tokenfield script
     $this->registerClientScript();
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $hasModel = $this->hasModel();
     if ($hasModel) {
         if (array_key_exists('value', $this->options)) {
             $value = $this->options['value'];
         } else {
             $value = Html::getAttributeValue($this->model, $this->attribute);
         }
     } else {
         $value = $this->value;
     }
     $altValue = $value;
     if ($hasModel) {
         $this->options = array_merge($this->options, ['name' => false, 'value' => $value]);
         $this->altOptions['value'] = $altValue;
         $output = Html::activeTextInput($this->model, $this->attribute, $this->options) . Html::activeHiddenInput($this->model, $this->attribute, $this->altOptions);
     } else {
         $output = Html::textInput(false, $value, $this->options) . Html::hiddenInput($this->name, $altValue, $this->altOptions);
     }
     $js = 'jQuery(\'#' . $this->options['id'] . '\').inputmask(' . Json::htmlEncode($this->clientOptions) . ').keyup(function (event) { jQuery(\'#' . $this->altOptions['id'] . '\').val(jQuery(this).inputmask(\'unmaskedvalue\')); });';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         InputMaskAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }