From ee9cb1ccce8dff49ffd5c81e0429031a3f94d9fe Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 27 May 2025 11:44:56 +0300 Subject: [PATCH] ERP-417 --- erp24/views/write_offs_erp/_form.php | 50 +++++++++++++--------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 435332cc..6b250bd9 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -257,37 +257,25 @@ JS [ 'name' => 'videoFiles', 'title' => 'Видео: mp4, mov, avi', - 'type' => FileInput::className(), - 'options' => function ($data) { + 'type' => 'raw', + 'value' => function ($data, $index) { $videoUrl = null; if (!empty($data['id'])) { - $videoUrl = Files::find() + $videoUrl = \common\models\Files::find() ->select('url') ->where([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity' => \common\models\WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] ]) ->scalar(); } - $videoPreviewHtml = ''; - if ($videoUrl) { - $videoPreviewHtml = '
- -
'; - } - - return [ + $input = \kartik\file\FileInput::widget([ + 'name' => "MultiModel[$index][videoFiles]", 'options' => [ - 'multiple' => false, 'accept' => 'video/*', - 'name' => 'video_name', - 'capture' => '', - 'class' => 'videos' + 'class' => 'videos', ], 'pluginOptions' => [ 'showPreview' => false, @@ -304,18 +292,26 @@ JS 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], 'initialPreview' => $videoUrl ? [$videoUrl] : [], 'initialPreviewAsData' => true, - 'initialCaption' => $videoUrl ? basename($videoUrl) : '', 'initialPreviewConfig' => $videoUrl ? [[ 'type' => 'video', 'caption' => basename($videoUrl), - 'url' => Url::to(['delete-video', 'id' => $data['id']]), + 'url' => \yii\helpers\Url::to(['delete-video', 'id' => $data['id']]), ]] : [], - ], - 'groupOptions' => [ - 'class' => 'd-flex align-items-center', - 'template' => '{input}' . $videoPreviewHtml, - ], - ]; + 'initialCaption' => $videoUrl ? basename($videoUrl) : '', + ] + ]); + + $videoTag = ''; + if ($videoUrl) { + $videoTag = '
+ +
'; + } + + return '
' . $input . $videoTag . '
'; } ], [ -- 2.39.5