Blame view

backend/views/book/_form.php 3.46 KB
8f340aa7   Anastasia   - main page
1
2
3
  <?php
      
      use artbox\core\admin\assets\Switchery;
ad2187ad   Anastasia   - book, author in...
4
      use artbox\core\helpers\ImageHelper;
8f340aa7   Anastasia   - main page
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      use dosamigos\tinymce\TinyMce;
      use kartik\select2\Select2;
      use yii\helpers\Html;
      use yii\helpers\Url;
      use yii\web\JsExpression;
      use yii\web\View;
      use yii\widgets\ActiveForm;
      
      /* @var $this yii\web\View */
      /* @var $model \common\models\Book */
      /* @var $form yii\widgets\ActiveForm */
      
      Switchery::register($this);
      $js = <<< JS
  $('.switchery').each(function(idx, elem) {
    new Switchery(elem, {
      color:'#46b749',
      secondaryColor:'#e2e2e2'
    });
  });
  
  JS;
      
      
      $this->registerJs($js, View::POS_READY);
  ?>
  
  <div class="feedback-form">
      
      <?php $form = ActiveForm::begin(); ?>
      
      <?= $form->field($model, 'title')
               ->textInput([ 'maxlength' => true ]) ?>
ad2187ad   Anastasia   - book, author in...
38
39
40
41
      <div class="form-group">
      <?=ImageHelper::set('@storage/books/'.$model->id.'/'.$model->image)->cropResize(262, 390)->renderImage()?>
      </div>
    <?=$model->author->name.' '.$model->author->secondname?>
8f340aa7   Anastasia   - main page
42
43
44
45
46
47
48
49
50
51
52
53
54
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
      
      <?= $form->field($model, 'description')
               ->widget(
                   TinyMce::className(),
                   [
                       'options'       => [ 'rows' => 30 ],
                       'language'      => 'ru',
                       'clientOptions' => [
                           'file_browser_callback' => new JsExpression(
                               "function(field_name, url, type, win) {
  window.open('" . Url::to(
                                   [
                                       'imagemanager/manager',
                                       'view-mode'   => 'iframe',
                                       'select-type' => 'tinymce',
                                   ]
                               ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
  }"
                           ),
                           'plugins'               => [
                               "advlist autolink lists link charmap print preview anchor",
                               "searchreplace visualblocks code fullscreen",
                               "insertdatetime media table contextmenu paste image",
                           ],
                           'toolbar'               => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code",
                           'image_advtab'          => true,
                       ],
                   ]
               ); ?>
      
      <?= $form->field($model, 'preview')
               ->textarea(
                   [
                       'rows' => '10',
                   ]
               ) ?>
    
    
      
      <?= $form->field($model, 'status')->widget(
          Select2::classname(),
          [
              'data'          => $model->getStatuses(),
              'pluginOptions' => [
                  'allowClear' => true,
              ],
          ]
      );
              ?>
ad2187ad   Anastasia   - book, author in...
91
92
      <?= $form->field($model, 'price')
               ->textInput() ?>
8f340aa7   Anastasia   - main page
93
94
95
96
97
98
      <?= $form->field($model, 'on_main')
               ->checkbox(
                   [
                       'class' => 'switchery',
                   ]
               ) ?>
ad2187ad   Anastasia   - book, author in...
99
      
8f340aa7   Anastasia   - main page
100
101
102
103
104
105
106
107
108
109
      <div class="form-group">
          <?= Html::submitButton(
              $model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'),
              [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
          ) ?>
      </div>
      
      <?php ActiveForm::end(); ?>
  
  </div>