<?php

use kartik\widgets\FileInput;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

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

<div class="product-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'type')->dropDownList(
            $model::TypesWithLabels(),
        [
                'prompt' => 'Выберите Тип...',
        ]
    ) ?>

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

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

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

    <?= $form->field($model, 'status')->dropDownList([1 => 'Активен', 0 => 'Не активен'])?>

    <?= $form->field($model, 'photo')->widget(FileInput::class, [
        'pluginOptions' => [
            'showZoom' => false,
            'initialPreview' => [
                $model->photo != null ? Html::img('@frontend/web/images/product/' . $model->photo, ['class' => 'file-preview-image']) : null,
            ],
            'overwriteInitial' => true,
            'showCaption' => false,
            'showUpload' => false,
            'showRemove' => true,
            'showDetails' => true,
            'browseClass' => 'btn btn-primary btn-block',
            'browseIcon' => '<i class="fa fa-camera"></i> ',
            'browseLabel' => 'Выберите фото',
        ],
    ]) ?>

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

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

    <?= $form->field($model, 'strength')->dropDownList(
            $model::TabacooStrengthWithLabel()
    ) ?>

    <?= $form->field($model, 'category_id')->dropDownList(
            \yii\helpers\ArrayHelper::map(\common\models\Category::find()->asArray()->all(), 'id', 'name')
    ) ?>

    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
    </div>

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

</div>
