<?php

use common\models\Slider;
use common\modules\file\widgets\ImageUploader;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

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

<div class="slider-image-form">

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

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


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

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

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

    <?= $form->field($model, 'status')->widget(Select2::className(),([
        'name' => 'status',
        'hideSearch' => true,
        'data' => [1 => 'Active', 2 => 'Inactive'],
        'options' => ['placeholder' => 'Select status...'],
        'pluginOptions' => [
            'allowClear' => true
        ]
    ])) ?>

    <?= $form->field($model, 'sort')->textInput() ?>

    <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>
