Blame view

artweb/artbox-weblog/views/blog-category/_form.php 2.47 KB
c5b72fe5   mzavalniuk   add artbox to repo
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
  <?php
      
      use artbox\core\components\imagemanager\components\ImageManagerInputWidget;
      use artbox\core\widgets\LanguageForm;
      use artbox\weblog\models\Category;
      use artbox\weblog\models\CategoryLang;
      use kartik\select2\Select2;
      use yii\helpers\Html;
      use yii\web\View;
      use yii\widgets\ActiveForm;
      
      /**
       * @var View           $this
       * @var Category       $model
       * @var ActiveForm     $form
       * @var CategoryLang[] $modelLangs
       * @var array          $parentCategories
       */
  ?>
  
  <div class="blog-category-form">
      
      <?php $form = ActiveForm::begin(
          [
              'options' => [ 'enctype' => 'multipart/form-data' ],
          
          ]
      ); ?>
      
      <?php
          echo LanguageForm::widget(
              [
                  'modelLangs' => $modelLangs,
                  'formView'   => '@artbox/weblog/views/blog-category/_form_language',
                  'form'       => $form,
              ]
          );
      ?>
      
      <?= $form->field($model, 'image_id')
               ->widget(
                   ImageManagerInputWidget::className(),
                   [
                       'aspectRatio'                  => ( 16 / 9 ),
                       //set the aspect ratio
                       'showPreview'                  => true,
                       //false to hide the preview
                       'showDeletePickedImageConfirm' => false,
                       //on true show warning before detach image
                   ]
               ); ?>
      
      <?= $form->field($model, 'sort')
               ->textInput() ?>
      
      <?php echo $form->field($model, 'parent_id')
                      ->widget(
                          Select2::className(),
                          [
                              'data'          => $parentCategories,
                              'options'       => [ 'placeholder' => \Yii::t('blog', 'Has no parent rubric') ],
                              'pluginOptions' => [
                                  'allowClear' => true,
                              ],
                          ]
                      );
      ?>
      
      <?= $form->field($model, 'status')
               ->checkbox(
                   [
                       'class' => 'flat',
                   ]
               ) ?>
    
    <div class="form-group">
        <?= Html::submitButton(
            $model->isNewRecord ? 'Create' : 'Update',
            [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
        ) ?>
    </div>
      
      <?php ActiveForm::end(); ?>
  
  </div>