Exemplo n.º 1
2
 public function renderSavedValueInput()
 {
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     if ($value !== null && $value !== '') {
         // format value according to saveDateFormat
         try {
             $value = Yii::$app->formatter->asDate($value, $this->saveDateFormat);
         } catch (InvalidParamException $e) {
             // ignore exception and keep original value if it is not a valid date
         }
     }
     $this->options['savedValueInputID'] = $this->options['id'] . '-saved-value';
     $options = $this->options;
     $options['id'] = $options['savedValueInputID'];
     $options['value'] = $value;
     // render hidden input
     if ($this->hasModel()) {
         $contents = Html::activeHiddenInput($this->model, $this->attribute, $options);
     } else {
         $contents = Html::hiddenInput($this->name, $value, $options);
     }
     return $contents;
 }
Exemplo n.º 2
2
 public static function defaultColumns()
 {
     return ['fqdn' => ['attribute' => 'fqdn', 'value' => function ($model) {
         return $model->fqdn;
     }], 'type' => ['value' => function ($model) {
         return strtoupper($model->type);
     }], 'value' => ['value' => function ($model) {
         return $model->getValueText();
     }], 'zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'actions' => ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'visibleButtonsCount' => 2, 'options' => ['style' => 'width: 15%'], 'buttons' => ['update' => function ($url, $model, $key) {
         if ($model->is_system) {
             return Html::tag('div', Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record was created by hosting panel automatically and cannot be updated'), 'style' => 'display: inline-block; cursor: not-allowed;']);
         }
         $data = Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs edit-dns-toggle', 'data' => ['record_id' => $model->id, 'hdomain_id' => $model->hdomain_id, 'load-url' => Url::to(['@dns/record/update', 'hdomain_id' => $model->hdomain_id, 'id' => $model->id])]]);
         $progress = Json::htmlEncode("<tr><td colspan='5'>" . Progress::widget(['id' => 'progress-bar', 'percent' => 100, 'barOptions' => ['class' => 'active progress-bar-striped', 'style' => 'width: 100%']]) . '</td></tr>');
         Yii::$app->view->registerJs("\n                            \$('.edit-dns-toggle').click(function () {\n                                var record_id = \$(this).data('id');\n                                var hdomain_id = \$(this).data('hdomain_id');\n\n                                var currentRow = \$(this).closest('tr');\n                                var newRow = \$({$progress});\n\n                                \$(newRow).data({'record_id': record_id, hdomain_id: hdomain_id});\n                                \$('tr').filter(function () { return \$(this).data('id') == record_id; }).find('.btn-cancel').click();\n                                \$(newRow).insertAfter(currentRow);\n\n                                jQuery.ajax({\n                                    url: \$(this).data('load-url'),\n                                    type: 'GET',\n                                    timeout: 0,\n                                    error: function() {\n\n                                    },\n                                    success: function(data) {\n                                        newRow.find('td').html(data);\n                                        newRow.find('.btn-cancel').on('click', function (event) {\n                                            event.preventDefault();\n                                            newRow.remove();\n                                        });\n                                    }\n                                });\n\n                            });\n                        ");
         return $data;
     }, 'delete' => function ($url, $model, $key) {
         if ($model->type === 'ns' && $model->is_system) {
             return Html::tag('div', Html::a('<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record is important for the domain zone viability and can not be deleted'), 'style' => 'display: inline-block; cursor: not-allowed;']);
         }
         return ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => ['action' => Url::to('@dns/record/delete')], 'button' => ['class' => 'btn btn-default btn-xs', 'label' => '<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
             echo Html::activeHiddenInput($model, 'hdomain_id');
             echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
         }]);
     }]]];
 }
Exemplo n.º 3
1
 public function init()
 {
     parent::init();
     \Yii::setAlias('@webuploader', __DIR__);
     if (empty($this->driver)) {
         $this->driver = isset(\Yii::$app->params['webuploader_driver']) ? \Yii::$app->params['webuploader_driver'] : 'local';
     }
     if ($this->driver == 'local') {
         // 初始化@static别名,默认@web/static,最好根据自己的需求提前设置好@static别名
         $static = \Yii::getAlias('@static', false);
         $staticroot = \Yii::getAlias('@staticroot', false);
         if (!$static || !$staticroot) {
             \Yii::setAlias('@static', '@web/static');
             \Yii::setAlias('@staticroot', '@webroot/static');
         }
     }
     $this->server = $this->server ?: Url::to(['/site/webupload', 'driver' => $this->driver]);
     $this->options['boxId'] = isset($this->options['boxId']) ? $this->options['boxId'] : 'picker';
     $this->options['previewWidth'] = isset($this->options['previewWidth']) ? $this->options['previewWidth'] : '250';
     $this->options['previewHeight'] = isset($this->options['previewHeight']) ? $this->options['previewHeight'] : '150';
     if ($this->hasModel()) {
         $this->hiddenInput = Html::activeHiddenInput($this->model, $this->attribute);
     } else {
         $this->hiddenInput = Html::hiddenInput($this->name, $this->value);
     }
 }
Exemplo n.º 4
1
 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);
 }
Exemplo n.º 5
1
 public function autocompleteJui($opts)
 {
     $id = $this->getInputId();
     $options = array_merge_recursive(['id' => $id . '_autoComplete', 'clientOptions' => ['select' => new JsExpression("function( event, ui ) { \$( '#{$id}' ).val( ui.item.id ); }"), 'change' => new JsExpression("function(){ if( \$( '#{$id}' ).val() <= 0 ){ \$(this).val(null); }}"), 'search' => new JsExpression("function(){ \$( '#{$id}' ).val(null); }")]], $opts);
     $hidden = Html::activeHiddenInput($this->model, $this->attribute);
     $autocomplete = AutoComplete::widget($options);
     Yii::$app->getView()->registerJs("\$('body').on('autocompletecreate', 'input', function(e, ui){" . "\$(this).addClass('form-control') });", View::POS_END, 'autocompletecreate');
     $this->parts['{input}'] = $hidden . $autocomplete;
     return $this;
 }
Exemplo n.º 6
0
 public function init()
 {
     $value = $this->model->{$this->attribute};
     if (is_int($value) || is_float($value) || is_string($value) && strlen($value)) {
         $this->inputOptions['value'] = Text::date($this->dateFormat . $this->separator . $this->timeFormat, $value);
         $this->hiddenInputOptions['value'] = Text::date($this->altDateFormat . $this->altSeparator . $this->altTimeFormat, $value);
     }
     if (!$this->readOnly) {
         $pluginOptions = array_merge(['numberOfMonths' => 3, 'showButtonPanel' => true, 'altFieldTimeOnly' => false], $this->pluginOptions, ['dateFormat' => Text::juiDateFormat($this->dateFormat), 'altFormat' => Text::juiDateFormat($this->altDateFormat), 'separator' => $this->separator, 'altSeparator' => $this->altSeparator, 'timeFormat' => Text::juiTimeFormat($this->timeFormat), 'altTimeFormat' => Text::juiTimeFormat($this->altTimeFormat)]);
         $inputId = Html::getInputId($this->model, $this->attribute);
         $pluginOptions['altField'] = '#' . $inputId . '-alt';
         $js = 'jQuery(\'#' . $inputId . '\').datetimepicker(' . Json::encode($pluginOptions) . ');';
         $this->inputOptions['name'] = false;
         $this->hiddenInputOptions['id'] = $inputId . '-alt';
         $this->template .= "\n{hiddenInput}";
         $this->parts['{hiddenInput}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenInputOptions);
         if (Yii::$app->getRequest()->getIsAjax()) {
             $this->template .= "\n{script}";
             $this->parts['{script}'] = Html::script($js);
         } else {
             $view = $this->form->getView();
             TimePickerAsset::register($view);
             $view->registerJs($js);
         }
     }
     parent::init();
 }
Exemplo n.º 7
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()));
}
Exemplo n.º 8
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);
     }
 }
Exemplo n.º 9
0
 public function run()
 {
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         $attributeId = Html::getInputId($this->model, $this->attribute);
         $id = Html::getInputId($this->model, 'hydra_' . $this->attribute);
         $name = Html::getInputName($this->model, 'hydra_' . $this->attribute);
         $this->value = $this->model[$this->attribute];
     } else {
         $replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options);
         $name = $id = 'hydra_' . $this->name;
         $attributeId = $this->name;
     }
     $fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName;
     $replace['{preview}'] = 'Файл еще не загружен';
     if (!empty($this->value)) {
         $replace['{preview}'] = $this->value;
         $extension = Yii::$app->hydra->getExtension($this->value);
         if (Yii::$app->hydra->isImage($extension)) {
             $replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']);
         }
         $replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options']));
     }
     $replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options']));
     return strtr($this->template, $replace);
 }
Exemplo n.º 10
0
 public function init()
 {
     $id = $this->getId();
     $options = Json::htmlEncode(ArrayHelper::merge($this->options, ['uploader' => ['backendUrl' => Url::to($this->url)], 'files' => $this->getFiles(), 'multiple' => $this->multiple]));
     $this->getView()->registerJs("jQuery('#{$id}').fileInput({$options})");
     echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => $id]);
 }
Exemplo n.º 11
0
 public function staticField($value = false)
 {
     if (!$value) {
         $value = $this->model->{$this->attribute};
     }
     $this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute) . '<div class="form-control-static">' . $value . '</div>';
     return $this;
 }
Exemplo n.º 12
0
 public function hiddenInput($options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $this->parts['{label}'] = false;
     $this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options);
     return $this;
 }
Exemplo n.º 13
0
 private function renderInput()
 {
     if ($this->hasModel()) {
         return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     } else {
         return Html::hiddenInput($this->name, $this->value, $this->options);
     }
 }
Exemplo n.º 14
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->registerAssets();
     if ($this->name === null) {
         return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     }
     return Html::hiddenInput($this->name, $this->value, $this->options);
 }
Exemplo n.º 15
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     } else {
         return Html::hiddenInput($this->name, '', $this->options);
     }
 }
Exemplo n.º 16
0
 public function renderWidget()
 {
     if ($this->hasModel()) {
         $result = Html::activeHiddenInput($this->model, $this->attribute);
     } else {
         $result = Html::hiddenInput($this->name, $this->value);
     }
 }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->registerClientScript();
     if ($this->hasModel()) {
         echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => null]) . Html::activeInput('file', $this->model, $this->attribute, $this->options);
     } else {
         echo Html::hiddenInput($this->name, $this->value, ['id' => null]) . Html::input('file', $this->name, $this->value, $this->options);
     }
 }
Exemplo n.º 19
0
 public function run()
 {
     $inputId = Html::getInputId($this->model, $this->attribute);
     $dropzoneId = $inputId . '-dropzone-widget';
     $out = Html::activeHiddenInput($this->model, $this->attribute);
     $out .= Html::tag('div', '', ['id' => $dropzoneId, 'class' => 'dropzone ' . (isset($this->options['class']) ? $this->options['class'] : '')]);
     $this->registerJs($inputId, $dropzoneId);
     return $out;
 }
Exemplo n.º 20
0
 public static function printHiddenFields($images)
 {
     echo '<div id="images">';
     foreach ($images as $i => $image) {
         echo Html::activeHiddenInput($image, "[{$i}]file_id", ['value' => $image->file_id, 'class' => 'input-image-file_id']);
         echo Html::activeHiddenInput($image, "[{$i}]is_main", ['value' => $image->is_main, 'class' => 'input-image-is_main']);
     }
     echo '</div>';
 }
Exemplo n.º 21
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::hiddenInput($this->name, $this->value, $this->options);
     }
     $this->registerClientScript();
 }
Exemplo n.º 22
0
 protected function createInput()
 {
     if (!isset($this->clientOptions['onDayClick'])) {
         $this->clientOptions['onDayClick'] = new JsExpression('function(cell, content, date) {
             console.log(cell, content, date);
             jQuery("#' . Html::getInputId($this->model, $this->attribute) . '").val();
         }');
     }
     echo Html::activeHiddenInput($this->model, $this->attribute, $this->inputOptions);
 }
Exemplo n.º 23
0
 /**
  * 
  * @param ActiveRecord $model
  * @param type $key
  * @param type $index
  * @return type
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     $result = Html::tag('span', $index + 1, ['class' => 'serial-column']);
     if ($model instanceof ActiveRecord && ($primaryKeys = $model->primaryKey()) != []) {
         foreach ($primaryKeys as $primary) {
             $result .= ' ' . Html::activeHiddenInput($model, "[{$index}]{$primary}");
         }
     }
     return $result;
 }
Exemplo n.º 24
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>
     ';
 }
Exemplo n.º 25
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     $this->registerClientScript();
     if ($this->hasModel()) {
         $input = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     } else {
         $input = Html::hiddenInput($this->name, $this->value, $this->options);
     }
     echo strtr($this->template, ['{input}' => $input, '{jstree}' => Html::tag('div', '', ['id' => $this->getJsTreeId()])]);
 }
Exemplo n.º 26
0
 public function reayOnly($value = null, $options = [])
 {
     $options = array_merge($this->inputOptions, $options);
     $this->adjustLabelFor($options);
     $value = $value === null ? Html::getAttributeValue($this->model, $this->attribute) : $value;
     $options['class'] = 'da-style';
     $options['style'] = 'display: inline-block;';
     $this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute) . Html::tag('span', $value, $options);
     return $this;
 }
Exemplo n.º 27
0
 /**
  * @return string bootstrap-picker button with hiddenInput field where we put selected value
  */
 public function run()
 {
     if ($this->hasModel()) {
         $inp = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     } else {
         $inp = Html::hiddenInput($this->name, $this->value, $this->options);
     }
     $picker = Html::button('Выберите иконку', $this->pickerOptions);
     return Html::tag('div', $picker . $inp, $this->containerOptions);
 }
Exemplo n.º 28
-1
 /**
  * @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;
 }
Exemplo n.º 29
-1
    public function registerJs()
    {
        AssetsCallBack::register($this->getView());
        $js = "mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n                \$('#' + id).val(file.url); return true;\n            });\n            \$('#" . $this->buttonOptions['id'] . "').click(function(){\n                mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});";
        $this->getView()->registerJs($js);
        $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n                var img;\n                if((\"url\" in file )){\n                    img = templateItem.replace('{src}', file.url).replace('{src}', file.url);\n                    \$('#{$this->previewId}').append(img);\n                } else {\n                    file.forEach(function(item){\n                        img = templateItem.replace('{src}', item.url).replace('{src}', item.url);\n                        \$('#{$this->previewId}').append(img);\n                    });\n                }\n                return true;}); ");
        $hiddenInput = Html::activeHiddenInput($this->model, $this->attribute . '[]', ['value' => '{src}']);
        $templateJS = 'var templateItem = \'<div class="image-preview-wrap">
  <div class="image-preview">
    <img src="{src}" alt="">
  </div>
  <div class="delete-button">
    <a class="delete-image">
      <span class="glyphicon glyphicon-remove"></span>
    </a>
  </div>
  ' . $hiddenInput . '
</div>\';';
        $this->getView()->registerJs(str_replace(["\r", "\n"], '', $templateJS), \yii\web\View::POS_END);
        $deleteJs = '$(document).on("click", ".delete-button", function(){$(this).parent().remove()});';
        $this->getView()->registerJs($deleteJs);
        $this->view->registerCss('.form-img-preview {max-width:100px;}');
        $this->view->registerCss('.image-preview img {max-width:200px;}');
        $this->view->registerCss('.image-preview-wrap {position: relative;display: inline-block;max-width: 200px;margin: 10px;}');
        $this->view->registerCss('.delete-button {top: 0;position: absolute;right: 0;}');
    }
Exemplo n.º 30
-1
 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);
 }