]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Tue, 27 May 2025 08:47:12 +0000 (11:47 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 27 May 2025 08:47:12 +0000 (11:47 +0300)
erp24/views/write_offs_erp/_form.php

index 75c81b1eb3a9e380059d03bf2af0f3ae95ea1d96..435332cc7a7123d8abee9fb495dd24715b5112ab 100644 (file)
@@ -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 = '<div class="video-preview" style="margin-left: 20px;">
+                <video controls width="200">
+                    <source src="' . Html::encode($videoUrl) . '" type="video/mp4">
+                    Ваш браузер не поддерживает видео.
+                </video>
+            </div>';
+                        }
+
+                        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 = '<div style="margin-left: 20px;">
-                <video controls width="200">
-                    <source src="' . \yii\helpers\Html::encode($videoUrl) . '" type="video/mp4">
-                    Ваш браузер не поддерживает видео.
-                </video>
-            </div>';
-                        }
-
-                        return '<div style="display: flex; align-items: center;">' . $input . $videoTag . '</div>';
+                            ],
+                            'groupOptions' => [
+                                'class' => 'd-flex align-items-center',
+                                'template' => '{input}' . $videoPreviewHtml,
+                            ],
+                        ];
                     }
                 ],
                 [