Blame view

views/category/_form.php 4.3 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
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
      use yii\helpers\Html;

      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')) ?>

      

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

               ->widget(

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

                   [

                       'language'      => 'ru',

                       'options'       => [

                           'accept'   => 'image/*',

                           'multiple' => false,

                       ],

                       'pluginOptions' => [

                           'allowedFileExtensions' => [

                               'jpg',

                               'gif',

                               'png',

                           ],

2e22f66f   Yarik   Links fixed
57
                           'initialPreview'        => !empty( $model->imageUrl ) ? ArtboxImageHelper::getImage(

b7e90569   Yarik   Namespaces
58
59
60
61
62
63
64
65
66
                               $model->imageUrl,

                               'list'

                           ) : '',

                           'overwriteInitial'      => true,

                           'showRemove'            => false,

                           'showUpload'            => false,

                           'previewFileType'       => 'image',

                       ],

                   ]

fa743cfe   Yarik   Catalog + home pa...
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
               ); ?>

      

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

               ->widget(

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

                   [

                       'language'      => 'ru',

                       'options'       => [

                           'accept'   => 'image/*',

                           'multiple' => false,

                       ],

                       'pluginOptions' => [

                           'allowedFileExtensions' => [

                               'jpg',

                               'gif',

                               'png',

                           ],

                           'initialPreview'        => !empty( $model->getImageUrl(1, false) ) ? ArtboxImageHelper::getImage(

                               $model->getImageUrl(1, false),

                               'list'

                           ) : '',

                           'overwriteInitial'      => true,

                           'showRemove'            => false,

                           'showUpload'            => false,

                           'previewFileType'       => 'image',

                       ],

                   ]

b7e90569   Yarik   Namespaces
94
95
96
97
98
               ); ?>

      

      <?= LanguageForm::widget(

          [

              'modelLangs' => $modelLangs,

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

b7e90569   Yarik   Namespaces
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
              '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>