<?php
    
    use artbox\core\admin\widgets\ImageInput;
    use common\models\Settings;
    use kartik\file\FileInput;
    use yii\bootstrap\ActiveForm;
    use yii\web\View;
    
    /**
     * @var View       $this
     * @var Settings   $model
     * @var ActiveForm $form
     */
    
    if (!empty($model->logo)) {
            $logo[]  = '<img src="/storage/logo/' . $model->logo . '" class="file-preview-image kv-preview-data rotate-35921 is-portrait-gt4" style="width:200px;" title="' . $model->logo . '">';
            $config  = ["url" => "delete-image", "key" => 0, 'extra' => ['image' => $model->logo]];
        
    } else {
        $logo = [];
        $config = [];
    }
    echo '<div class="wrapp-blocks-edit-page">';
    echo $form->field($model, 'name')
              ->textInput();


    echo '</div>';
    echo '<div class="wrapp-blocks-edit-page">';
    echo FileInput::widget(
        [
            'name'          => 'logo',
            'options'       => [
                'multiple' => false,
                'accept'   => 'image/*',
            ],
            'pluginOptions' => [
                'maxFileCount'     => 9,
                'showUpload'       => false,
                'removeClass'      => 'btn btn-danger',
                'removeIcon'       => '<i class="glyphicon glyphicon-trash"></i> ',
                            'initialPreview'   => $logo,
                'overwriteInitial' => true,
                'initialPreviewConfig'        => $config
            ],
        ]
    );
    //    echo $form->field($model, 'logo')
//              ->widget(
//                  ImageInput::className(),
//                  [
//                      'showPreview'                  => true,
//                      'showDeletePickedImageConfirm' => false,
//                  ]
//              );
    echo '</div>';
    echo '<div class="style">';
        foreach ($model->getVariationModels() as $index => $variationModel){
            echo '<div style="display: none" class="">';
            echo $form->field($variationModel, '[' . $index . ']' . 'language_id')
                      ->hiddenInput()->label(false);

            echo $form->field($variationModel, '[' . $index . ']' . 'settings_id')
                ->hiddenInput()->label(false);


            echo $form->field($variationModel, '[' . $index . ']' . 'id')
                      ->hiddenInput(['value' => $index])->label(false);
            echo '</div>';
            echo '<div class="tabs-lang" '.($index > 0 ? 'style="display:none"' : '').'>';
            echo $form->field($variationModel, '[' . $index . ']' . 'about')
                      ->textarea()->label(\Yii::t('core', 'About us' ).' ('.$variationModel->language->url.')');
            echo '</div>';
        }
     echo '</div>';
    
?>
