From: marina Date: Mon, 26 May 2025 07:45:42 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7d0bbb956c330034736b08ca806352f3a267151a;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 1bae11c0..cb9f52c8 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -260,9 +260,7 @@ JS 'title' => 'Видео: mp4, mov, avi', 'type' => FileInput::className(), 'value' => function ($data) { - if ($data === null || !isset($data['id'])) { - return null; - } + if (!$data || !isset($data['id'])) return null; $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] @@ -278,22 +276,17 @@ JS ], 'pluginOptions' => [ 'showPreview' => true, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - 'browseIcon' => '+', - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', - 'fileActionSettings' => [ - 'showUpload' => false, - 'showZoom' => false, - 'showDrag' => false - ], + 'showCaption' => true, // ✅ Должно быть true + 'initialCaption' => function($data) { // ✅ Добавляем название файла + if (!$data || !isset($data['id'])) return 'Файл не выбран'; + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? basename($file->url) : 'Файл не выбран'; + }, 'initialPreview' => function($data) { - if ($data === null || !isset($data['id'])) { - return []; - } + if (!$data || !isset($data['id'])) return []; $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] @@ -301,44 +294,22 @@ JS return $file ? [Yii::getAlias('@web') . $file->url] : []; }, 'initialPreviewConfig' => function($data) { - if ($data === null || !isset($data['id'])) { - return []; - } + if (!$data || !isset($data['id'])) return []; $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] ]); - if (!$file) { - return []; - } - $filePath = Yii::getAlias('@webroot') . $file->url; - return [[ - 'caption' => basename($file->url), + return $file ? [[ + 'caption' => basename($file->url), // ✅ Обязательно! 'type' => 'video', - 'size' => file_exists($filePath) ? filesize($filePath) : 0, - 'filetype' => mime_content_type($filePath) // (опционально) - ]]; + 'size' => @filesize(Yii::getAlias('@webroot') . $file->url), + ]] : []; }, - 'initialPreviewAsData' => true, - 'previewSettings' => [ - 'video' => '{width}: "100%", height: "auto"' - ], - 'previewTemplates' => [ - 'video' => '
{caption}
' - ], - 'maxFileSize' => 51200, - 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], - 'maxFileCount' => 1, - 'layoutTemplates' => [ - 'main1' => '{preview}
{remove}{cancel}{upload}{browse}' - ] ], - 'model' => $multipleUploadForm, ], 'columnOptions' => [ - 'class' => 'custom_css_class_file_input', - 'style' => 'min-width: 240px;' - ] + 'style' => 'min-width: 240px; overflow: visible;', // ✅ Убедитесь, что не hidden + ], ], [ 'name' => 'comment',