当前位置: 首页>>代码示例>>PHP>>正文


PHP Html::fileInput方法代码示例

本文整理汇总了PHP中yii\helpers\Html::fileInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::fileInput方法的具体用法?PHP Html::fileInput怎么用?PHP Html::fileInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Html的用法示例。


在下文中一共展示了Html::fileInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $field = Html::activeFileInput($this->model, $this->attribute, $this->options);
     } else {
         $field = Html::fileInput($this->name, $this->value, $this->options);
     }
     echo $this->renderTemplate($field);
     $this->registerPlugin();
 }
开发者ID:mirocow,项目名称:yii2-file-input-widget,代码行数:13,代码来源:FileInput.php

示例2: renderInput

 protected function renderInput()
 {
     $fileButton = '<span class="input-group-addon"><span class="fileinput-button">' . '<i class="glyphicon glyphicon-plus"></i>' . '<span data-loading-text="上传中...">上传图片 ...</span>' . Html::fileInput($this->getFileInputName(), '', ['id' => $this->getFileInputId(), 'class' => 'single-file-upload']) . '</span></span>';
     if ($this->hasModel()) {
         $input = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $input = Html::textInput($this->name, '', $this->options);
     }
     return '<div class="input-group">' . $input . $fileButton . '</div>';
 }
开发者ID:mztest,项目名称:yii2-single-file-upload,代码行数:10,代码来源:SingleFileUpload.php

示例3: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $jsOptions = ['clientOptions' => $this->clientOptions];
     $this->options['id'] = 'input-id';
     if ($this->hasModel()) {
         echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
         $input_name = Html::getInputName($this->model, $this->attribute);
         $input_id = Html::getInputId($this->model, $this->attribute);
         echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
         $jsOptions['model'] = $this->model;
         $jsOptions['attribute'] = $this->attribute;
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
     }
     if ($this->uploadUrl) {
         $this->uploadUrl = \Yii::getAlias($this->uploadUrl);
     }
     $jsOptions['uploadUrl'] = $this->uploadUrl;
     $jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
     $jsOptions['changeUrl'] = $this->changeUrl;
     $jsOptions['name'] = $this->name;
     $jsOptions['aspectRatio'] = $this->aspectRatio;
     $this->registerPlugin($jsOptions);
 }
开发者ID:servsol,项目名称:yii2-cropper,代码行数:31,代码来源:Cropper.php

示例4: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $input = $this->hasModel() ? Html::activeFileInput($this->model, $this->attribute, $this->options) : Html::fileInput($this->name, $this->value, $this->options);
     echo $this->render('uploadButton', ['input' => $input]);
     $this->registerClientScript();
 }
开发者ID:pranshupraneta,项目名称:yii2-materialize-file-upload-widget,代码行数:9,代码来源:FileUpload.php

示例5: field

    private static function field($key, $value, $sModel, $model)
    {
        if (strpos($sModel, "listT(") === 0) {
            $modelName = str_replace("listT(", "", $sModel);
            $modelName = str_replace(")", "", $modelName);
            $type = substr($modelName, strpos($modelName, '[') + 1, strpos($modelName, '[') - strpos($modelName, ']') + 1);
            //echo $type;
            //exit;
            $modelName = str_replace("[" . $type . "]", "", $modelName);
            $temp = ArrayHelper::map($modelName::findAllByType($type), 'id', 'name');
            $temp[''] = Yii::t('app', 'None');
            //$label = Yii::t('app', $sModel->id) ;
            $field = Html::dropDownList($model . '[' . $key . '][value]', $value, $temp) . "<br/>";
        } elseif (strpos($sModel, "list(") === 0) {
            $modelName = str_replace("list(", "", $sModel);
            $modelName = str_replace(")", "", $modelName);
            $temp = ArrayHelper::map($modelName::find()->All(), 'id', 'name');
            $temp[''] = Yii::t('app', 'None');
            //$label = Yii::t('app', $sModel->id) ;
            $field = \kartik\select2\Select2::widget(["name" => $model . '[' . $key . '][value]', "data" => $temp, "value" => $value]);
        } elseif (strpos($sModel, "select(") === 0) {
            $list = str_replace("select(", "", $sModel);
            //echo str_replace(")", "", $list);
            //exit;
            $list = Json::decode(str_replace(")", "", $list));
            foreach ($list as &$item) {
                //print $item;
                $item = Yii::t('app', $item);
            }
            //$temp = Html::listData(\yii\helpers\Json::decode($list), 'id', 'name');
            $temp[''] = Yii::t('app', 'None');
            //$label = Yii::t('app', $sModel->id);
            $field = \kartik\select2\Select2::widget(["name" => $model . '[' . $key . '][value]', "data" => $list, "value" => $value]);
        } elseif ($sModel == 'file') {
            $rKey = str_replace(".", "", $key);
            //$label = Yii::t('app', $sModel->id) ;
            $field = "<div class='row'><div class='btn-group '>" . Html::fileInput($model . '[' . $key . '][value]', $value, ['style' => 'display:none;', 'id' => $model . "_" . $rKey . "_input", "accept" => "image/gif,image/jpeg"]) . Html::hiddenInput($model . '[' . $key . '][value]', $value) . Html::buttonInput(Yii::t('app', 'Chose'), ['id' => $model . "_" . $rKey . "_upload"]) . Html::buttonInput(Yii::t('app', 'Delete'), ['id' => $model . "_" . $rKey . "_remove"]) . "</div></div>";
            $idf = $model . "_" . $rKey . "_input";
            $script = "\n                    \$(document).on('click','#{$model}_{$rKey}_upload', function () {\n                        \$('#{$idf}').click();\n                    });\n                    \$(document).on('click','#{$model}_{$rKey}_remove', function () {\n                        //del();\n                    });\n                        \n                    ";
            Yii::$app->controller->view->registerJs($script, \yii\web\View::POS_READY);
        } elseif ($sModel == 'boolean') {
            //$label = Yii::t('app', $sModel->id);
            $field = Html::hiddenInput($model . '[' . $key . '][value]', false) . Html::checkbox($model . '[' . $key . '][value]', $value == 'true' ? true : false, ['class' => 'form-control']);
        } elseif ($sModel == 'date') {
            //$label = Yii::t('app', $sModel->id);
            $name = str_replace("[", "_", str_replace("]", "_", $model));
            $id = $name . "-" . $key;
            $rname = $model . "[" . $key . "][value]";
            $timezone = Yii::$app->timezone;
            $base = yii\helpers\BaseUrl::base();
            $field = <<<java
                    <div class="input-group date">
                        <span class="input-group-addon kv-date-calendar" title="Select date">
                            <i class="glyphicon glyphicon-calendar"></i>
                        </span>
                    <input type="text" id="{$id}-disp" class="form-control" name="{$rname}-w0" value="{$value}" data-krajee-datecontrol="datecontrol_b5142286" data-datepicker-type="2" data-krajee-kvdatepicker="kvDatepicker_158f0063"></div>
                    <input type="hidden" id="{$id}" name="{$rname}">
                    <script>
                        var kvDatepicker_158f0063 = {"autoclose":true,"format":"dd/mm/yyyy"};
                        var datecontrol_37eef6f1 = {"idSave":"{$id}","url":"{$base}/datecontrol/parse/convert","type":"date","saveFormat":"Y-m-d","dispFormat":"d/m/Y","asyncRequest":true};
                        jQuery('#{$id}-disp').datecontrol(datecontrol_37eef6f1);
                        jQuery('#{$id}-disp').parent().kvDatepicker(kvDatepicker_158f0063);
                    </script>
java;
            //$field.="<script>jQuery('#{$name}{$key}_value').datepicker();</script>";
        } else {
            //$label = Yii::t('app', $sModel->id);
            $field = Html::textInput($model . '[' . $key . '][value]', $value, ['class' => 'form-control']);
        }
        return $field;
    }
开发者ID:chaimvaid,项目名称:linet3,代码行数:71,代码来源:EAVHelper.php

示例6: run

 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);
 }
开发者ID:zabachok,项目名称:yii2-hydra,代码行数:26,代码来源:FileInput.php

示例7: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeFileInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
     }
     $this->registerClientScript();
 }
开发者ID:2amigos,项目名称:yii2-file-input-widget,代码行数:12,代码来源:BootstrapFileInput.php

示例8: run

 /**
  * 输出模板内容
  * @return string
  */
 public function run()
 {
     $this->registerClientScript();
     if ($this->hasModel()) {
         $input = Html::activeTextInput($this->model, $this->attribute, $this->options);
         $fileInput = Html::fileInput(Html::getInputName($this->model, $this->attribute));
     } else {
         $input = Html::textInput($this->name, $this->value, $this->options);
         $fileInput = Html::fileInput($this->name, $this->value);
     }
     $button = Html::tag('div', $fileInput . '<span>' . $this->buttonText . '</span>', $this->buttonOptions);
     return strtr($this->template, ['{id}' => $this->getId(), '{input}' => $input, '{button}' => $button]);
 }
开发者ID:panfake,项目名称:yii2-wechat,代码行数:17,代码来源:FileApi.php

示例9: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         echo Html::activeFileInput($this->model, $this->attribute, $this->options);
         if (!$this->ratio || !$this->crop_field || !$this->url) {
             foreach ($this->model->getBehaviors() as $beh) {
                 if (!empty($beh->attribute) && $beh->attribute == $this->attribute) {
                     if ($beh instanceof CropImageUploadBehavior) {
                         if (!$this->ratio && $beh->ratio) {
                             $this->ratio = $beh->ratio;
                         }
                         if (!$this->crop_field && $beh->crop_field) {
                             $this->crop_field = $beh->crop_field;
                         }
                         if (!$this->url && $beh->url) {
                             $this->url = $beh->url;
                         }
                         break;
                     }
                 }
             }
         }
         if (!$this->crop_value && $this->crop_field) {
             $this->crop_value = $this->model->{$this->crop_field};
         }
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
     }
     $crop_id = false;
     if ($this->crop_field) {
         if ($this->hasModel()) {
             $crop_id = Html::getInputId($this->model, $this->crop_field);
             echo Html::activeHiddenInput($this->model, $this->crop_field, ['value' => $this->crop_value]);
         } else {
             $crop_id = $this->options['id'] . '_' . $this->crop_field;
             echo Html::hiddenInput($this->crop_field, $this->crop_value);
         }
     }
     if ($this->url) {
         $this->url = \Yii::getAlias($this->url);
     }
     $jsOptions = ['crop_value' => $this->crop_value, 'crop_id' => $crop_id, 'ratio' => $this->ratio, 'url' => $this->resolvePath($this->url), 'clientOptions' => $this->clientOptions, 'is_crop_prev' => $crop_id || !$this->hasModel() ? false : true, 'crop_class' => $this->crop_class];
     $this->registerPlugin($jsOptions);
 }
开发者ID:andasoft,项目名称:yii2-core,代码行数:47,代码来源:CropImageUpload.php

示例10: run

 public function run()
 {
     echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     $groups_id = $this->attribute;
     $items = array();
     if ($this->model->{$groups_id}) {
         foreach (GlImgs::find()->where(['groups_id' => $this->model->{$groups_id}])->orderBy(['seq' => SORT_ASC])->all() as $i => $image) {
             $items[] = ['content' => Html::tag('div', Html::button(null, ['class' => 'btn btn-default btn-xs glyphicon glyphicon-remove', 'onclick' => 'removeUploadImage("' . $this->pluginOptions['url'] . '", ' . $image->id . ', "' . $image->basename_src . '", ' . $image->groups_id . ')']), ['style' => 'background:url("' . $image->img_small . '") 50% 50% no-repeat;', 'class' => 'upload-img', 'data-imgs-id' => $image->id, 'id' => 'upload-img-' . $image->id])];
         }
     }
     $items[] = ['content' => '<span class="glyphicon glyphicon-plus"></span><br>Добавить фото' . Html::fileInput(null, null, ['multiple' => true, 'data-url' => $this->pluginOptions['url'], 'data-type' => $this->pluginOptions['type'], 'data-input-id' => strtolower($this->model->formName()) . '-' . $groups_id, 'onchange' => 'prepareUpload($(this))', 'id' => 'js-upload-action']), 'disabled' => true, 'options' => ['class' => 'js-upload', 'onclick' => 'openFileDiaolg()']];
     echo Html::beginTag('div', ['class' => 'upload-gallery-content']);
     echo Sortable::widget(['type' => 'grid', 'items' => $items, 'pluginEvents' => ['sortupdate' => 'function(data) {reSortGallery("' . $this->pluginOptions['url'] . '")}'], 'options' => ['class' => 'js-upload-gallery']]);
     echo Html::tag('div', 'Основное изображение', ['class' => 'js-upload-image-default']);
     echo Html::endTag('div');
     /*echo Html::tag('div', '<small>Вы можете прикрепить не более 5 фотографий</small>', [
           'class' => 'text-muted',
       ]);*/
     $view = $this->view;
     UploadGalleryAsset::register($view);
 }
开发者ID:mark38,项目名称:yii2-tor,代码行数:21,代码来源:UploadGallery.php

示例11: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $jsOptions = ['clientOptions' => $this->clientOptions, 'crop_class' => $this->crop_class];
     if ($this->hasModel()) {
         echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
         $crops = null;
         foreach ($this->model->getBehaviors() as $beh) {
             if (!empty($beh->attribute) && $beh->attribute == $this->attribute && $beh instanceof CropImageUploadBehavior) {
                 $crops = $beh->getConfigurations();
                 $this->url = $beh->url;
                 break;
             }
         }
         if (!$crops) {
             throw new InvalidConfigException("CropImageUploadBehavior is not found for {$this->attribute} attribute");
         }
         $jsOptions['crops'] = [];
         $input_name = Html::getInputName($this->model, $this->attribute);
         $input_id = Html::getInputId($this->model, $this->attribute);
         echo Html::hiddenInput($input_name . '[file]', Html::getAttributeValue($this->model, $this->attribute), ['id' => $input_id . '_image']);
         foreach ($crops as $ind => $crop) {
             $crop_id = $input_id . '_crop' . $ind;
             echo Html::hiddenInput($input_name . '[' . $ind . ']', $crop['value'] === false ? '-' : $crop['value'], ['id' => $crop_id]);
             $jsOptions['crops'][] = ['input_id' => $crop_id, 'ratio' => $crop['ratio'], 'image' => $crop['image']];
         }
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
         $crop_id = (isset($this->options['id']) ? $this->options['id'] : $this->name . '_id') . '_' . $this->crop_field;
         echo Html::hiddenInput($this->crop_field, $this->crop_value, ['id' => $crop_id]);
         $jsOptions['crops'][] = ['input_id' => $crop_id, 'ratio' => $this->ratio];
     }
     if ($this->url) {
         $this->url = \Yii::getAlias($this->url);
     }
     $jsOptions['url'] = $this->url;
     $this->registerPlugin($jsOptions);
 }
开发者ID:karpoff,项目名称:yii2-crop-image-upload,代码行数:40,代码来源:CropImageUpload.php

示例12:

$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Products'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
?>

    <div class="form-group">
        <?php 
echo Html::label(Yii::t('app', 'Import File CSV'), 'importFile', ['class' => 'col-lg-1 control-label']);
?>
        <?php 
echo Html::fileInput('importFile');
?>
    </div>

    <div class="form-group">
        <label class="col-lg-1 control-label" for="">&nbsp;</label>
        <?php 
echo Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
开发者ID:CTaiDeng,项目名称:funshop,代码行数:31,代码来源:import.php

示例13: renderData

 /**
  * Render data block
  * @return string
  */
 protected function renderData()
 {
     $data = '';
     //file
     $options = ['accept' => 'image/jpeg,image/png,image/gif', 'id' => 'upload-image'];
     if ($this->multiple) {
         $options['multiple'] = 'multiple';
     }
     $data .= Html::fileInput($this->fileInputName, '', $options);
     //attributes
     $a = [];
     $a[$this->fileKey] = '';
     if ($this->thumbKey !== null) {
         $a[$this->thumbKey] = '';
     }
     $a = array_merge($a, $this->data);
     foreach ($a as $key => $value) {
         $data .= Html::hiddenInput($this->baseName . '[' . $key . ']', $value, ['disabled' => $this->disabledInput]);
     }
     return Html::tag('div', $data, ['class' => 'uploadimage-data']);
 }
开发者ID:dkhlystov,项目名称:yii2-uploadimage,代码行数:25,代码来源:Loader.php

示例14: run

 /**
  * @return string
  */
 public function run()
 {
     $this->registerClientScript();
     $content = Html::beginTag('div');
     $content .= Html::hiddenInput($this->name, null, ['class' => 'empty-value', 'id' => $this->options['id']]);
     $content .= Html::fileInput($this->getFileInputName(), null, ['name' => $this->getFileInputName(), 'id' => $this->getId(), 'multiple' => $this->multiple]);
     $content .= Html::endTag('div');
     return $content;
 }
开发者ID:sonrac,项目名称:yii2-file-kit,代码行数:12,代码来源:Upload.php

示例15:

                <?php 
// $context->model instanceof \yii\base\Model && $context->attribute !== null
//                     ? Html::activeFileInput($context->model, $context->attribute, $context->fieldOptions)
//                     : Html::fileInput($context->name, $context->value, $context->fieldOptions);
?>

<!--             </span> -->
            <div class="file-upload">
				<div class="div-file">
					<input type="file"> <span class="btn-admin gray fileinput-button">Choose New File</span>
					<span class="text">No file chosen</span>
					
				</div>
				<button type="submit" class="btn-admin start">upload</button>
				 <?php 
echo $context->model instanceof \yii\base\Model && $context->attribute !== null ? Html::activeFileInput($context->model, $context->attribute, $context->fieldOptions) : Html::fileInput($context->name, $context->value, $context->fieldOptions);
?>
			</div>
<!--             <button type="submit" class="btn btn-primary start"> -->
<!--                 <i class="glyphicon glyphicon-upload"></i> -->
<!--                 <span>Start upload</span> -->
<!--             </button> -->
<!--             <button type="reset" class="btn btn-warning cancel"> -->
<!--                 <i class="glyphicon glyphicon-ban-circle"></i> -->
<!--                 <span>Cancel upload</span> -->
<!--             </button> -->
<!--             <button type="button" class="btn btn-danger delete"> -->
<!--                 <i class="glyphicon glyphicon-trash"></i> -->
<!--                 <span>Delete</span> -->
<!--             </button> -->
<!--             <input type="checkbox" class="toggle"> -->
开发者ID:veerkun,项目名称:sunfrog,代码行数:31,代码来源:form.php


注:本文中的yii\helpers\Html::fileInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。