<?php
    
    /**
     * @var View             $this
     * @var ImageManager     $model
     * @var ImageManagerLang $languages
     */
    
    use artbox\core\components\imagemanager\models\ImageManager;
    use artbox\core\components\imagemanager\models\ImageManagerLang;
    use common\models\Language;
    use yii\helpers\Html;
    use yii\web\View;

?>


<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    
    
    <?php
        
        foreach (Language::getActive() as $id => $language) { ?>
          
          
          <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="heading<?= $id ?>">
              <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?= $id ?>" aria-expanded="true" aria-controls="collapseOne">
                    <?= $language->name ?>
                </a>
              </h4>
            </div>
            <div id="collapse<?= $id ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?= $id ?>">
              <div class="panel-body">
                  
                  <?php
                      if (empty($languages[ $id ])) { ?>
                        
                        <div class="form-group">
                          <label for="title<?= $id ?>">Title</label>
                          <input name="image_info[<?= $language->id ?>][title]" type="text" class="form-control" id="title<?= $id ?>">
                        </div>
                        
                        <div class="form-group">
                          <label for="alt<?= $id ?>">Alt</label>
                          <input name="image_info[<?= $language->id ?>][alt]" type="text" class="form-control" id="alt<?= $id ?>">
                        </div>
                        
                        <div class="form-group">
                          <label for="description<?= $id ?>">Description</label>
                          <textarea class="form-control" name="image_info[<?= $language->id ?>][description]" id="description<?= $id ?>" cols="30" rows="10"></textarea>
                        </div>
                      
                      <?php } else { ?>
                        
                        <div class="form-group">
                          <label for="title<?= $id ?>">Title</label>
                          <input value="<?= $languages[ $id ]->title ?>" name="image_info[<?= $language->id ?>][title]" type="text" class="form-control" id="title<?= $id ?>">
                        </div>
                        
                        <div class="form-group">
                          <label for="alt<?= $id ?>">Alt</label>
                          <input value="<?= $languages[ $id ]->alt ?>" name="image_info[<?= $language->id ?>][alt]" type="text" class="form-control" id="alt<?= $id ?>">
                        </div>
                        
                        <div class="form-group">
                          <label for="description<?= $id ?>">Description</label>
                          <textarea class="form-control" name="image_info[<?= $language->id ?>][description]" id="description<?= $id ?>" cols="30" rows="10"><?= $languages[ $id ]->description ?></textarea>
                        </div>
                      
                      <?php } ?>
              </div>
            </div>
          </div>
            
            <?php
        }
        echo Html::hiddenInput(
            'image_id',
            $model->id
        );
    
    ?>

</div>



