<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <?php
            /**
             * @var $this WaterMarkController
             * @var BHorizontalForm $form
             * @var WaterMarkModel $model
             */
            ?>

            <?php $form = $this->beginWidget('BHorizontalForm',
            array(
                'enableAjaxValidation' => false,
            ));

//            echo $form->beginControlGroup($model, 'serverFile');
//            $this->widget('ServerFileInput', array(
//                    'model' => $model,
//                    'attribute' => 'serverFile',
//                )
//            );
//            echo $form->endControlGroup($model);

//            echo $form->hiddenField($model, 'serverFile');
            $fileInputName = CHtml::activeName($model, 'serverFile[]');

            $this->widget('ElFinderWidget', array('settings' => array(
                'closeOnEditorCallback' => false,
                'selectMultiple' => true,
                'editorCallback' => 'js:function(files) {
                        var file;
                        $("#images").html("");
                        for(var i=0;i<files.length; i++){
                            file = files[i];
                            $("#images").append(
                              $("<div/>")
                              .append($("<p/>").text(decodeURI(file)))
                              .append($("<input type=hidden name=' . $fileInputName . '>").attr("value",decodeURI(file)))
                              );
                        }
                     }',
            )));

//            echo '<img id="editedImage" src="' . ($model->serverFile ? $model->serverFile . '?' . rand() : '') . '"/>';



            ?>
            <div id="images">
                <?php
                if (Yii::app()->user->hasFlash('images')) {
                    foreach (Yii::app()->user->getFlash('images') as $img) {
                        echo '<p>', $img, '</p>';
                    }
                }
                ?>
            </div>
            <div>
                <button class="btn btn-primary" type="submit">Добавить водяной знак</button>
                <br/>
            </div>
            <?php $this->endWidget();?>
        </div>
    </div>
</div>