<?php
    
    use yii\helpers\Html;
    use yii\widgets\ActiveForm;
    
    /* @var $this yii\web\View */
    /* @var $model common\models\Certificate */
    /* @var $form yii\widgets\ActiveForm */
?>

<div class="certificate-form">
    
    <?php $form = ActiveForm::begin([
        'options' => [
            'enctype' => 'multipart/form-data',
        ],
    ]); ?>
    
    <?= $form->field($model, 'name')
             ->textInput([ 'maxlength' => true ]) ?>
    
    <?php
        echo $form->field($model, 'file')
                  ->widget(\kartik\file\FileInput::className(), [
                      'language'      => 'ru',
                      'pluginOptions' => [
                          'allowedFileExtensions' => [
                              'pdf',
                          ],
                          'initialPreview'        => $model->getCertificateUrl() ? : '',
                          'showUpload'            => false,
                          'showRemove'            => false,
                          'previewFileType'       => 'image',
                      ],
                  ]);
    ?>
    
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
    </div>
    
    <?php ActiveForm::end(); ?>

</div>
