From 02c21c76a91934aeefd99656ed422100aaa42500 Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 26 May 2025 13:12:23 +0300 Subject: [PATCH] =?utf8?q?=D1=81=D1=83=D0=BC=D0=BC=D0=B8=D1=80=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?utf8?q?=D1=82=D0=BE=D0=B2=20=D0=B8=20=D0=B2=D1=8B=D1=87=D0=B8=D1=82?= =?utf8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B4=D0=B0=D0=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/views/write_offs_erp/_form.php | 38 ++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 1aa13999..ec59f13d 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -186,7 +186,7 @@ JS 'capture' => '', 'class' => 'file', 'required' => true, - ], + ], 'pluginOptions' => [ 'showPreview' => true, 'showCaption' => true, // ✅ Должно быть true @@ -270,21 +270,7 @@ JS 'entity_id' => $data['id'] ]); - if (!$file) return null; - - $initialPreview = [$file->url]; - $initialPreviewConfig = [[ - 'type' => 'video', - 'caption' => basename($file->url), - 'url' => Url::to(['delete-video', 'id' => $data['id']]) - ]]; - - return [ - 'caption' => basename($file->url), - 'url' => $file->url, - 'initialPreview' => $initialPreview, - 'initialPreviewConfig' => $initialPreviewConfig - ]; + return $file ? $file->url : null; // Return just the URL string }, 'options' => [ 'options' => [ @@ -301,6 +287,26 @@ JS 'allowedFileTypes' => ['video'], 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], 'maxFileSize' => 10240, + 'initialPreview' => function ($data) { + if (!$data || !isset($data['id'])) return []; + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [$file->url] : []; + }, + 'initialPreviewConfig' => function ($data) { + if (!$data || !isset($data['id'])) return []; + $file = Files::findOne([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $data['id'] + ]); + return $file ? [[ + 'type' => 'video', + 'caption' => basename($file->url), + 'url' => Url::to(['delete-video', 'id' => $data['id']]) + ]] : []; + } ], ], ], -- 2.39.5