Blame view

artweb/artbox-catalog/views/variant/_form_options.php 2.11 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
  <?php
      
      use artbox\catalog\models\Product;
      use artbox\catalog\models\ProductLang;
      use artbox\catalog\models\VariantOptionGroupCompl;
      use artbox\catalog\models\VariantOptionGroupExcl;
      use yii\helpers\ArrayHelper;
      use yii\web\View;
      use yii\widgets\ActiveForm;
      
      /**
       * @var ProductLang[]             $modelLangs
       * @var Product                   $model
       * @var ActiveForm                $form
       * @var View                      $this
       * @var VariantOptionGroupCompl[] $groups_compl
       * @var VariantOptionGroupExcl[]  $groups_excl
       */
  ?>
  <?php
      if (!empty( $groups_compl )) {
          foreach ($groups_compl as $group) {
              echo $form->field($model, 'variantOptionCompls')
                        ->checkboxList(
                            ArrayHelper::map(
                                $group->options,
                                'id',
                                'lang.value'
                            ),
                            [
                                'multiple'    => true,
                                'unselect'    => null,
                                'itemOptions' => [
                                    'class' => 'flat',
                                ],
                            ]
                        )
                        ->label($group->lang->title);
          }
      }
      if (!empty( $groups_excl )) {
          foreach ($groups_excl as $index => $group) {
              $optionIds = ArrayHelper::map(
                  $group->options,
                  'id',
                  'lang.value'
              );
              $optionIds = [ 0 => \Yii::t('catalog', 'Not set') ] + $optionIds;
              echo $form->field($model, "variantOptionExcls[$index]")
                        ->radioList(
                            $optionIds,
                            [
                                'unselect'    => null,
                                'itemOptions' => [
                                    'class' => 'flat',
                                ],
                            ]
                        )
                        ->label($group->lang->title);
          }
      }
  ?>