Example #1
2
 /**
  * @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);
 }
 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>
                             ';
 }
    /**
     * 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                );");
        }
    }
 /**
  * @inheritDoc
  */
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{beginWrapper'])) {
             $options = $this->wrapperOptions;
             $tag = ArrayHelper::remove($options, 'tag', 'div');
             $this->parts['{beginWrapper}'] = Html::beginTag($tag, $options);
             $this->parts['{endWrapper}'] = Html::endTag($tag);
         }
         if ($this->label === false) {
             $this->parts['{label}'] = '';
             $this->parts['{beginLabel}'] = '';
             $this->parts['{labelTitle}'] = '';
             $this->parts['{endLabel}'] = '';
         } elseif (!isset($this->parts['{beginLabel'])) {
             $this->parts['{beginLabel}'] = Html::beginTag('label', $this->labelOptions);
             $this->parts['{endLabel}'] = Html::endTag('label');
             $attribute = Html::getAttributeName($this->attribute);
             $this->parts['{labelTitle}'] = Html::encode($this->label ? $this->label : $this->model->getAttributeLabel($attribute));
         }
         if ($this->inputTemplate) {
             $input = isset($this->parts['{input}']) ? $this->parts['{input}'] : Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
             $this->parts['{input}'] = strtr($this->inputTemplate, ['{input}' => $input]);
         }
     }
     return parent::render($content);
 }
Example #5
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);
 }
Example #6
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()
 {
     // 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;
 }
 /**
  * @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 #10
0
 /**
  * @inheritdoc
  */
 public function textInput($options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $options);
     return $this;
 }
 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);
 }
 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 #13
0
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterDropdownOptions);
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Select::widget(['model' => $model, 'attribute' => $this->attribute, 'items' => $this->filter, 'options' => $options, 'search' => true]) . ' ' . $error;
         } else {
             $options = ['class' => 'fluid'];
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Elements::input(Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error, $options);
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Example #14
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 #15
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     $contents = [];
     if ($this->inline) {
         if ($this->hasModel()) {
             $contents[] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         } else {
             $contents[] = Html::hiddenInput($this->name, $this->value, $this->options);
         }
         $contents[] = Html::tag('div', '', $this->containerOptions);
     } else {
         if ($this->hasModel()) {
             $contents[] = Html::activeTextInput($this->model, $this->attribute, $this->options);
         } else {
             $contents[] = Html::textInput($this->name, $this->value, $this->options);
         }
     }
     echo implode("\n", $contents);
     if ($this->language) {
         DatePickerAsset::$extraJs[] = 'plugins/bootstrap-datepicker-extended/js/locales/bootstrap-datepicker.' . $this->language . '.js';
         $this->clientOptions['language'] = $this->language;
     }
     DatePickerAsset::register($this->view);
     $this->registerPlugin('datepicker');
     if ($this->inline) {
         $this->view->registerJs("\n                !(function(\$){\n                    var el = \$('#{$this->options['id']}'),\n                        val = el.val(),\n                        container = \$('#{$this->containerOptions['id']}');\n                    container.on('changeDate', function(e){\n                        el.val(e.format());\n                    });\n                    if(val) {\n                        container.datepicker('update', new Date(Date.parse(val)));\n                    }\n                })(jQuery);\n                ", View::POS_READY);
     }
 }
Example #16
0
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $labelsHelp = $this->model->attributeHints();
             if (isset($labelsHelp[$this->attribute])) {
                 $this->labelOptions['label'] = '<span data-toggle="tooltip" title="" data-original-title="';
                 $this->labelOptions['label'] .= Html::encode($labelsHelp[$this->attribute]);
                 $this->labelOptions['label'] .= '">';
                 $this->labelOptions['label'] .= Html::encode($this->model->getAttributeLabel($this->attribute));
                 $this->labelOptions['label'] .= ' <span class="glyphicon glyphicon-question-sign" style="font-size: 8pt;" aria-hidden="true"></span>';
                 $this->labelOptions['label'] .= '</span>';
             } else {
                 $this->labelOptions['label'] = Html::encode($this->model->getAttributeLabel($this->attribute));
             }
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return $this->begin() . "\n" . $content . "\n" . $this->end();
 }
Example #17
0
/**
 * 
 * @param biz\models\GlDetail $model
 * @param integer $index
 * @return string
 */
function renderRow($model, $index)
{
    ob_start();
    ob_implicit_flush(false);
    ?>
                    <tr>
                        <?php 
    echo Html::activeHiddenInput($model, "[{$index}]id_gl_detail");
    ?>
                        <td class="serial"><?php 
    echo $index;
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]id_coa");
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]debit");
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]kredit");
    ?>
</td>
                        <td class="action"><a class="fa fa-minus-square-o" href="#"></a></td>
                    </tr>
                    <?php 
    return trim(preg_replace('/>\\s+</', '><', ob_get_clean()));
}
 /**
  * @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 #19
0
 public function render($content = null)
 {
     $this->inputOptions['name'] = '';
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             // $this->inputOptions['data-bind'] = sprintf('value: %s', $this->attribute);
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{hidden}'])) {
             $this->parts['{hidden}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return empty($content) ? '' : ($this->wrapper ? $this->begin() . "\n" . $content . "\n" . $this->end() : $content);
 }
Example #20
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);
     }
 }
 /**
  * @param string $attribute
  *
  * @return string
  */
 public function getInputField($attribute)
 {
     if ($this->inputType == 'textArea') {
         return Html::activeTextarea($this->model, $attribute, $this->inputOptions);
     } else {
         return Html::activeTextInput($this->model, $attribute, $this->inputOptions);
     }
 }
Example #22
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);
     }
 }
Example #23
0
 public function run()
 {
     $this->view->registerJs('$("#' . $this->id . '").spectrum(' . json_encode($this->options) . ');');
     if ($this->model != null) {
         return Html::activeTextInput($this->model, $this->attribute, ['id' => $this->id]);
     } else {
         return Html::texInput($this->name, '', ['id' => $this->id]);
     }
 }
Example #24
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);
     }
 }
 /**
  * @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');
 }
 /**
  * @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 #27
0
 public function init()
 {
     parent::init();
     $this->data_id = isset($this->data_id) ? $this->data_id : 'id';
     $this->data_value = isset($this->data_value) ? $this->data_value : 'name';
     $this->nametitle = isset($this->nametitle) ? $this->nametitle : '';
     $this->registerAssets();
     echo Html::activeTextInput($this->model, $this->attribute, ['class' => 'hidden', 'value' => $this->value]);
 }
 /**
  * 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();
 }
Example #29
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);
     }
 }
Example #30
-1
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if ($this->format == 'boolean') {
         $this->filter = [\Yii::t('app', 'No'), \Yii::t('app', 'Yes')];
     }
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
             return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }