<?php
use yii\helpers\ArrayHelper;
use kartik\file\FileInput;

use common\modules\school\models\Courses;
use common\modules\testings\models\Test;

 $image = "<div class='file-widget'>".FileInput::widget([
        'model' => $model,
        'attribute' => 'filesUpload[]',
        'language' => 'en',
        'options' => ['multiple' => true, 'overwriteInitial'=>false],
        'pluginOptions' => ['showUpload' => false]
    ])."</div>";
 
$elements = [
    'test_id' => ['type' => 'dropdownlist', 'items' => ArrayHelper::map(Test::find()->all(), 'id', 'name', 'session.name'), 'empty' => 'Не задан'],
    'title'	=> ['type' => 'text'],
    'video_id'	=> ['type' => 'text'],
    'text' => ['type' => 'textarea'],
    'course_id' => [
            'type' => 'dropdownlist',
            'items' => ArrayHelper::map(Courses::find()->all(), 'id', 'title'),
        ],
    'number'	=> ['type' => 'text'],
    'image'	=> $image,
];

return [
    'activeForm'=>[
        'id' => 'lesson-form',
        'options' => [
            'enctype' => 'multipart/form-data'
        ],
    ],
    'elements'       => $elements,
    'buttons' => [
        'submit' => ['type' => 'submit', 'value' => 'Cохранить']
    ]
];

