<?php

use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use \yii\helpers\ArrayHelper;

use common\modules\school\models\Courses;

/* @var $this yii\web\View */
/* @var $searchModel common\modules\faq\models\SearchFaq */
/* @var $dataProvider yii\data\ActiveDataProvider */

?>

<p>
    <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>

<?php echo AdminGrid::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        'title',
         [
            'attribute' => 'video_id',
            'filter' => false,
            'value' => function($model)
            {
                return $model->video_id;
            }
        ],
        [
            'attribute' => 'course_id',
            'filter' => Html::dropDownList('SearchLessons[course_id]',
                    $searchModel->course_id,
                    ArrayHelper::map(Courses::find()->all(),'id','title'),
                    ['class'=>'form-control','prompt'=>'Курс']),
            'value' => function($model)
            {
                return $model->course->title;
            }
        ],
        'number',
        [
            'class' => 'common\components\ColorActionColumn',
            'template' => '{view} {update}',
        ],
    ],
]); ?>