<?php

use common\widgets\FieldEditor;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\modules\file\widgets\ImageUploader;
use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
use common\components\Request;

/* @var $this yii\web\View */
/* @var $model common\models\Blog */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="blog-form">

    <?php $form = ActiveForm::begin([
        'enableClientValidation' => false,
        'options' => ['enctype' => 'multipart/form-data']
    ]); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'description')->widget(CKEditor::className(),
        [
            'editorOptions' => ElFinder::ckeditorOptions('elfinder',[
                    'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать
                    'inline' => false, //по умолчанию false]),
                    'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload')
                ]
            )
        ]) ?>

    <?= $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
        'language' => 'ru',
        'options' => [
            'accept' => 'image/*',
            'multiple' => false,
        ],
        'pluginOptions' => [
            'allowedFileExtensions' => ['jpg', 'gif', 'png'],
            'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
            'overwriteInitial' => true,
            'showRemove' => false,
            'showUpload' => false,
            'previewFileType' => 'image',
        ],
    ]); ?>

    <?= FieldEditor::widget([
        'template' => 'education',
        'item_id'  => $model->blog_id,
        'model'    => 'common\models\Blog',
        'language' => 'ru',
    ]); ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
