Blame view

common/modules/product/views/manage/_form.php 3.78 KB
a8370482   Alexander Karnovsky   init project
1
2
3
4
5
6
7
  <?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  use yii\helpers\ArrayHelper;
  use common\components\artboxtree\ArtboxTreeHelper;
  use common\modules\product\helpers\ProductHelper;
b519af22   Karnovsky A   Base-product func...
8
9
10
  use kartik\file\FileInput;
  use unclead\widgets\MultipleInput;
  use unclead\widgets\MultipleInputColumn;
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
11
  use kartik\select2\Select2;
a8370482   Alexander Karnovsky   init project
12
13
14
15
16
17
18
19
20
21
22
23
  
  /* @var $this yii\web\View */
  /* @var $model common\modules\product\models\Product */
  /* @var $form yii\widgets\ActiveForm */
  ?>
  
  <div class="product-form">
  
      <?php $form = ActiveForm::begin(); ?>
  
      <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  
5aa7418e   Karnovsky A   Base-product#3 fu...
24
25
26
      <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
      <?= $form->field($model, 'video')->textarea()->label('Video embeded'); ?>
  
b519af22   Karnovsky A   Base-product func...
27
28
      <?= $form->field($model, 'brand_id')->dropDownList(
          ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),
a8370482   Alexander Karnovsky   init project
29
30
31
32
          [
              'prompt' => Yii::t('product', 'Select brand')
          ]
      ) ?>
b519af22   Karnovsky A   Base-product func...
33
  
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
34
      <?= $form->field($model, 'categories')->widget(Select2::className(), [
bce22e8a   Karnovsky A   Some refixes
35
              'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
36
              'language' => 'ru',
bce22e8a   Karnovsky A   Some refixes
37
38
39
40
41
42
43
              'options' => [
                  'placeholder' => 'Select a state ...',
                  'multiple' => true,
              ],
              'pluginOptions' => [
                  'allowClear' => true
              ],
a8370482   Alexander Karnovsky   init project
44
45
46
          ]
      ) ?>
  
5aa7418e   Karnovsky A   Base-product#3 fu...
47
48
49
  
  
      <?php /*= $form->field($model, 'imagesUpload[]')->widget(FileInput::classname(), [
b519af22   Karnovsky A   Base-product func...
50
51
52
53
          'options' => [
              'accept' => 'image/*',
              'multiple' => true,
          ],
5aa7418e   Karnovsky A   Base-product#3 fu...
54
      ]);*/?>
b519af22   Karnovsky A   Base-product func...
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
96
97
98
99
  
      <?= $form->field($model, 'variants')->widget(MultipleInput::className(), [
          'columns' => [
              [
                  'name'  => 'product_variant_id',
                  'type'  => MultipleInputColumn::TYPE_HIDDEN_INPUT,
              ],
              [
                  'name'  => 'name',
                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,
                  'title' => 'Name',
              ],
              [
                  'name'  => 'sku',
                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,
                  'title' => 'SKU',
              ],
              [
                  'name'  => 'price',
                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,
                  'title' => 'Price',
              ],
              [
                  'name'  => 'price_old',
                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,
                  'title' => 'Old Price',
              ],
              [
                  'name'  => 'product_unit_id',
                  'type'  => MultipleInputColumn::TYPE_DROPDOWN,
                  'title' => 'Unit',
                  'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'),
              ],
              [
                  'name'  => 'stock',
                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,
                  'title' => 'Stock',
                  'options' => [
                      'placeholder' => '∞'
                  ],
              ],
          ],
      ]);
      ?>
  
e16b79fd   Karnovsky A   Base-product#3 fu...
100
      <?php if(isset($groups)) :?>
5aa7418e   Karnovsky A   Base-product#3 fu...
101
102
103
104
105
106
107
108
109
      <?php  foreach($groups->all() as $group) :?>
          <?= $form->field($model, 'options')->checkboxList(
          ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'),
          [
              'multiple' => true,
              'unselect' => null,
          ]
          )->label($group->name);?>
      <?php endforeach?>
e16b79fd   Karnovsky A   Base-product#3 fu...
110
      <?php endif?>
5aa7418e   Karnovsky A   Base-product#3 fu...
111
  
a8370482   Alexander Karnovsky   init project
112
113
114
115
116
117
118
      <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']) ?>
      </div>
  
      <?php ActiveForm::end(); ?>
  
  </div>