Blame view

views/category/_form.php 5.25 KB
b7e90569   Yarik   Namespaces
1
2
  <?php

      

2e22f66f   Yarik   Links fixed
3
4
5
6
      use artweb\artbox\components\artboximage\ArtboxImageHelper;

      use artweb\artbox\language\widgets\LanguageForm;

      use artweb\artbox\ecommerce\models\Category;

      use artweb\artbox\ecommerce\models\CategoryLang;

b7e90569   Yarik   Namespaces
7
      use yii\helpers\Html;

2ffeed3d   Yarik   Image delete func...
8
      use yii\helpers\Url;

b7e90569   Yarik   Namespaces
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
38
39
40
41
42
      use yii\web\View;

      use yii\widgets\ActiveForm;

      

      /**

       * @var View           $this

       * @var Category       $model

       * @var CategoryLang[] $modelLangs

       * @var string[]       $categories

       * @var ActiveForm     $form

       * @var array          $parents

       */

  ?>

  

  <div class="category-form">

      

      <?php $form = ActiveForm::begin(

          [

              'enableClientValidation' => false,

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

          ]

      ); ?>

      

      <?= $form->field($model, 'parent_id')

               ->dropDownList(

                   $parents,

                   [

                       'prompt'  => Yii::t('rubrication', 'Root category'),

                       'options' => [

                           $model->id => [ 'disabled' => true ],

                       ],

                   ]

               )

               ->label(Yii::t('product', 'Parent category')) ?>

      

d89130bf   Yarik   Main page sort
43
44
45
46
47
48
49
50
      <?php

          echo $form->field($model, 'sort');

      ?>

      

      <?php

          echo $form->field($model, 'sort2');

      ?>

      

b7e90569   Yarik   Namespaces
51
52
53
54
55
56
57
58
      <?= $form->field($model, 'image')

               ->widget(

                   \kartik\file\FileInput::className(),

                   [

                       'language'      => 'ru',

                       'options'       => [

                           'accept'   => 'image/*',

                           'multiple' => false,

2ffeed3d   Yarik   Image delete func...
59
60
                           'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-image', 'id' => $model->id]),

                           'class'     => $model->isNewRecord?'':'artbox-delete-file',

b7e90569   Yarik   Namespaces
61
62
63
64
65
66
67
                       ],

                       'pluginOptions' => [

                           'allowedFileExtensions' => [

                               'jpg',

                               'gif',

                               'png',

                           ],

2ffeed3d   Yarik   Image delete func...
68
                           'initialPreview'        => !empty( $model->getImageUrl(0, false) ) ? ArtboxImageHelper::getImage(

b7e90569   Yarik   Namespaces
69
70
71
                               $model->imageUrl,

                               'list'

                           ) : '',

2ffeed3d   Yarik   Image delete func...
72
73
74
75
76
77
                           'initialPreviewShowDelete' => false,

                           'overwriteInitial'         => true,

                           'showRemove'               => true,

                           'showUpload'               => false,

                           'showClose'                => false,

                           'previewFileType'          => 'image',

b7e90569   Yarik   Namespaces
78
79
                       ],

                   ]

fa743cfe   Yarik   Catalog + home pa...
80
81
82
83
84
85
86
87
88
89
               ); ?>

      

      <?= $form->field($model, 'icon')

               ->widget(

                   \kartik\file\FileInput::className(),

                   [

                       'language'      => 'ru',

                       'options'       => [

                           'accept'   => 'image/*',

                           'multiple' => false,

2ffeed3d   Yarik   Image delete func...
90
91
                           'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-icon', 'id' => $model->id]),

                           'class'     => $model->isNewRecord?'':'artbox-delete-file',

fa743cfe   Yarik   Catalog + home pa...
92
93
94
95
96
97
98
                       ],

                       'pluginOptions' => [

                           'allowedFileExtensions' => [

                               'jpg',

                               'gif',

                               'png',

                           ],

d89130bf   Yarik   Main page sort
99
100
101
102
                           'initialPreview'        => !empty( $model->getImageUrl(

                               1,

                               false

                           ) ) ? ArtboxImageHelper::getImage(

fa743cfe   Yarik   Catalog + home pa...
103
104
105
                               $model->getImageUrl(1, false),

                               'list'

                           ) : '',

2ffeed3d   Yarik   Image delete func...
106
107
108
109
110
111
                           'initialPreviewShowDelete' => false,

                           'overwriteInitial'         => true,

                           'showRemove'               => true,

                           'showUpload'               => false,

                           'showClose'                => false,

                           'previewFileType'          => 'image',

fa743cfe   Yarik   Catalog + home pa...
112
113
                       ],

                   ]

b7e90569   Yarik   Namespaces
114
115
116
117
118
               ); ?>

      

      <?= LanguageForm::widget(

          [

              'modelLangs' => $modelLangs,

2e22f66f   Yarik   Links fixed
119
              'formView'   => '@artweb/artbox/ecommerce/views/category/_form_language',

b7e90569   Yarik   Namespaces
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
              'form'       => $form,

          ]

      ) ?>

      

      <div class="form-group">

          <?= Html::submitButton(

              $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'),

              [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]

          ) ?>

          <?php if ($model->isNewRecord) : ?>

              <?= Html::submitButton(

                  Yii::t('product', 'Create and continue'),

                  [

                      'name'  => 'create_and_new',

                      'class' => 'btn btn-primary',

                  ]

              ) ?>

          <?php endif ?>

      </div>

      

      <?php ActiveForm::end(); ?>

  

  </div>