<?php
    
    use common\models\Project;
    use common\models\ProjectLang;
    use common\modules\language\widgets\LanguageForm;
    use yii\helpers\Html;
    use yii\web\View;
    use yii\widgets\ActiveForm;
    use yii\jui\DatePicker;
    
    /**
     * @var View        $this
     * @var Project     $model
     * @var ProjectLang $model_langs
     * @var ActiveForm  $form
     */
?>

<div class="articles-form">
    
    <?php $form = ActiveForm::begin([
        'options' => [ 'enctype' => 'multipart/form-data' ],
    ]); ?>
    
    
    <?= $form->field($model, 'date_add')
             ->widget(DatePicker::className(), [
                 'dateFormat' => 'dd-MM-yyyy',
             ]) ?>
    
    <?= $form->field($model, 'imagesUpload[]')
             ->widget(\kartik\file\FileInput::className(), [
                 'language'      => 'ru',
                 'options'       => [
                     'accept'   => 'image/*',
                     'multiple' => true,
                 ],
                 'pluginOptions' => [
                     'allowedFileExtensions' => [
                         'jpg',
                         'gif',
                         'png',
                     ],
                     'initialPreview'        => !empty( $model->imagesHTML ) ? $model->imagesHTML : [],
                     'initialPreviewConfig'  => $model->imagesConfig,
                     'overwriteInitial'      => false,
                     'showRemove'            => false,
                     'showUpload'            => false,
                     'uploadAsync'           => !empty( $model->project_id ),
                     'previewFileType'       => 'image',
                 ],
             ]); ?>
    
    <?= LanguageForm::widget([
        'model_langs' => $model_langs,
        'formView'    => '@backend/views/project/_form_language',
        'form'        => $form,
    ]) ?>
    
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? \Yii::t('app', 'Create') : \Yii::t('app', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
    </div>
    
    <?php ActiveForm::end(); ?>

</div>
