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