Использую для мультизагрузки файлов dosamigos FileUploadUI. По умолчанию отображаются кнопки "Добавить файлы", "Начать загрузку", "Отменить загрузку" и "Удалить". Что нужно сделать, чтобы оставить только одну кнопку "Добавить файлы", а остальные удалить?
В представлении код:
Спасибо! Отобразилось то что нужно. Но при нажатии на кнопку "Добавить файлы" ничего не происходит. В консоли сразу после загрузки страницы с формой (еще даже при ненажатой кнопке "Добавить файлы"):
jquery.js:3850 Uncaught TypeError: Cannot read property 'innerHTML' of null
at Function.r.load (tmpl.js:40)
at r (tmpl.js:23)
at $.<computed>.<computed>._initTemplates (jquery.fileupload-ui.js:661)
at $.<computed>.<computed>._initTemplates (jquery.ui.widget.js:148)
at $.<computed>.<computed>._initSpecialOptions (jquery.fileupload-ui.js:681)
at $.<computed>.<computed>._initSpecialOptions (jquery.ui.widget.js:148)
at $.<computed>.<computed>._create (jquery.fileupload.js:1439)
at $.<computed>.<computed>._create (jquery.ui.widget.js:148)
at $.<computed>.<computed>._super (jquery.ui.widget.js:133)
at $.<computed>.<computed>._create (jquery.fileupload-process.js:170)
<?php
/** @var \dosamigos\fileupload\FileUploadUI $this */
use yii\helpers\Html;
$context = $this->context;
?>
<!-- The file upload form used as target for the file upload widget -->
<?= Html::beginTag('div', $context->options); ?>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-12">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span><?= Yii::t('fileupload', 'Add files') ?>...</span>
<?= $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>
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-5 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width:0%;"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"> </div>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
<?= Html::endTag('div');?>
Последний раз редактировалось yura1976 2019.09.14, 16:11, всего редактировалось 1 раз.
yiiliveext писал(а): ↑2019.09.14, 16:46
Я же написал, что нужно переделать template, убрав ненужные кнопки, а не выдумывать свою вьюху, которая отдает html.
Этот template - для отображения выбранных файлов и кнопок загрузки для уже выбранных. Т.е., Ваше предложение использовать uploadTemplateView - верное, но template - не тот (vendor/2amigos/yii2-file-upload-widget/src/views/upload.php). Я взял vendor/2amigos/yii2-file-upload-widget/src/views/form.php и убрал лишнее, своего ничего не добавлял. Теперь кнопка отображается та, что и должна, но в результате загрузки страницы консоль показывает ошибку, которую я привел, а при клике на кнопку "Загрузить файлы" ничего не происходит.