Blame view

backend/views/banner/_form.php 2.93 KB
4253cbec   root   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <?php

  

  use common\modules\file\widgets\ImageUploader;

  use kartik\select2\Select2;

  use yii\helpers\Html;

  use yii\widgets\ActiveForm;

  

  /* @var $this yii\web\View */

  /* @var $model common\models\Banner */

  /* @var $form yii\widgets\ActiveForm */

  ?>

  

  <div class="banner-form">

  

82f961f9   Administrator   big commti
15
16
17
18
      <?php $form = ActiveForm::begin([

          'enableClientValidation' => false,

          'options' => ['enctype' => 'multipart/form-data']

      ]); ?>

4253cbec   root   first commit
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  

  

      <?= $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

          ]

      ])) ?>

  

4ef97d76   Administrator   big commti
37
  

2cbb3bdc   Виталий   test commit
38
      <div id="image_widget_block">

82f961f9   Administrator   big commti
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  

          <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [

              'language' => 'ru',

              'options' => [

                  'accept' => 'image/*',

                  'multiple' => false,

              ],

              'pluginOptions' => [

                  'allowedFileExtensions' => ['jpg', 'gif', 'png'],

                  'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',

                  'overwriteInitial' => true,

                  'showRemove' => false,

                  'showUpload' => false,

                  'previewFileType' => 'image',

              ],

          ]); ?>

4253cbec   root   first commit
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
      </div>

  

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

  <script>

      $('#save_image_widget_settings').click(function(){

          var width = $('#banner-width').val();

          var height = $('#banner-height').val();

          save_image_widget_settings( width, height, function(data){

              $('#image_widget_block').html = '';

              $('#image_widget_block').html(data.html);

          });

      });

      function save_image_widget_settings( width, height, callback )

      {

          $.ajax({

              url: '/admin/banner/save-image-settings',

              data        :

              {

                  'width'       : width,

                  'height'   : height

              },

              type : 'POST',

              dataType: 'json',

              success: function (data)

              {

                  if(callback)

                      callback(data);

              },

              error: function()

              {

                  console.info('error');

              }

          });

      }

  </script>