Blame view

artweb/artbox-catalog/views/variant-option-group-compl/_form.php 3.4 KB
16f1e516   mzavalniuk   add artbox-catalo...
1
2
3
4
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
38
39
40
41
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  <?php
      
      use artbox\catalog\models\OptionGroup;
      use artbox\catalog\models\OptionGroupLang;
      use artbox\core\widgets\LanguageForm;
      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 OptionGroupLang[] $modelLangs
       * @var OptionGroup       $model
       * @var ActiveForm        $form
       * @var View              $this
       */
  ?>
  
  <div class="product-form">
      
      <?php $form = ActiveForm::begin(); ?>
      
      <?php
          echo Select2::widget(
              [
                  'name'          => 'categoryIds',
                  'options'       => [
                      'placeholder' => \Yii::t('catalog', 'Search for a categories ...'),
                      'multiple'    => true,
                  ],
                  'value'         => array_keys($model->categoryIds),
                  'data'          => $model->categoryIds,
                  'pluginOptions' => [
                      'allowClear'         => true,
                      'minimumInputLength' => 3,
                      'language'           => [
                          'errorLoading' => new JsExpression(
                              "function () { return 'Waiting for results...'; }"
                          ),
                      ],
                      'ajax'               => [
                          'url'      => Url::to([ '/category/list' ]),
                          'dataType' => 'json',
                          'data'     => new JsExpression(
                              'function(params) { 
                                      return {
                                          q:params.term
                                      }; 
                                   }'
                          ),
                      ],
                      'escapeMarkup'       => new JsExpression(
                          'function (markup) {
                                  return markup; 
                               }'
                      ),
                      'templateResult'     => new JsExpression(
                          'function (brand) { 
                                  return brand.text; 
                               }'
                      ),
                      'templateSelection'  => new JsExpression(
                          'function (brand) {
                                  return brand.text; 
                               }'
                      ),
                  ],
              ]
          );
      ?>
      
      <?= LanguageForm::widget(
          [
              'modelLangs' => $modelLangs,
              'formView'   => '@artbox/catalog/views/variant-option-group-compl/_form_language',
              'form'       => $form,
          ]
      ) ?>
      
      <?= $form->field($model, 'sort')
               ->textInput() ?>
      
      <?= $form->field($model, 'is_filter')
               ->checkbox(
                   [
                       'class' => 'flat',
                   ]
               ) ?>
      
      <?= $form->field($model, 'status')
               ->checkbox(
                   [
                       'class' => 'flat',
                   ]
               ) ?>
      
      <div class="form-group">
          <?= Html::submitButton(
              $model->isNewRecord ? Yii::t('catalog', 'Create') : Yii::t('catalog', 'Update'),
              [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
          ) ?>
      </div>
      
      <?php ActiveForm::end(); ?>
  
  </div>