Blame view

views/blog-article/_form.php 11.2 KB
593851ec   Alexey Boroda   First commit
1
2
  <?php
      
933c16cb   Yarik   Pre stable ready
3
      use artbox\core\components\imagemanager\components\ImageManagerInputWidget;
ba196ec2   Alexey Boroda   -Blog in process
4
5
      use artbox\weblog\models\Article;
      use artbox\weblog\models\ArticleLang;
ee588281   Alexey Boroda   -Blog backend ready
6
7
      use artbox\weblog\models\Category;
      use artbox\weblog\models\Tag;
593851ec   Alexey Boroda   First commit
8
      use kartik\select2\Select2;
593851ec   Alexey Boroda   First commit
9
10
11
12
      use yii\helpers\Html;
      use yii\helpers\Url;
      use yii\web\View;
      use yii\widgets\ActiveForm;
ba196ec2   Alexey Boroda   -Blog in process
13
      use artbox\core\widgets\LanguageForm;
593851ec   Alexey Boroda   First commit
14
15
16
      use yii\web\JsExpression;
      
      /**
ee588281   Alexey Boroda   -Blog backend ready
17
18
19
20
21
22
23
24
       * @var View          $this
       * @var Article       $model
       * @var ActiveForm    $form
       * @var ArticleLang[] $modelLangs
       * @var Category[]    $categories
       * @var Tag[]         $tags
       * @var array         $products
       * @var array         $articles
593851ec   Alexey Boroda   First commit
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
       */
  ?>
  
  <div class="blog-article-form">
      
      <?php $form = ActiveForm::begin(
          [
              'options' => [ 'enctype' => 'multipart/form-data' ],
          ]
      ); ?>
      
      <?php
          echo LanguageForm::widget(
              [
                  'modelLangs' => $modelLangs,
ba196ec2   Alexey Boroda   -Blog in process
40
                  'formView'   => '@artbox/weblog/views/blog-article/_form_language',
593851ec   Alexey Boroda   First commit
41
42
43
44
                  'form'       => $form,
              ]
          );
      ?>
ee588281   Alexey Boroda   -Blog backend ready
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    
    <div class="form-group">
      <label class="control-label"><?= \Yii::t('blog', 'Categories'); ?></label>
        <?php
            echo Select2::widget(
                [
                    'name'          => 'categoryIds',
                    'options'       => [
                        'placeholder' => \Yii::t('blog', '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([ '/blog-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; 
                               }'
                        ),
                    ],
                ]
            );
        ?>
    </div>
    
    <div class="form-group">
      <label class="control-label"><?= \Yii::t('blog', 'Tags'); ?></label>
        <?php
            echo Select2::widget(
                [
                    'name'          => 'tagIds',
                    'options'       => [
                        'placeholder' => \Yii::t('blog', 'Search for a tags ...'),
                        'multiple'    => true,
                    ],
                    'value'         => array_keys($model->tagIds),
                    'data'          => $model->tagIds,
                    'pluginOptions' => [
                        'allowClear'         => true,
                        'minimumInputLength' => 3,
                        'language'           => [
                            'errorLoading' => new JsExpression(
                                "function () { return 'Waiting for results...'; }"
                            ),
                        ],
                        'ajax'               => [
                            'url'      => Url::to([ '/blog-tag/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; 
                               }'
                        ),
                    ],
                ]
            );
        ?>
    </div>
593851ec   Alexey Boroda   First commit
149
      
ba196ec2   Alexey Boroda   -Blog in process
150
      <?= $form->field($model, 'image_id')
593851ec   Alexey Boroda   First commit
151
               ->widget(
ba196ec2   Alexey Boroda   -Blog in process
152
                   ImageManagerInputWidget::className(),
593851ec   Alexey Boroda   First commit
153
                   [
ba196ec2   Alexey Boroda   -Blog in process
154
155
156
157
158
159
                       'aspectRatio'                  => ( 16 / 9 ),
                       //set the aspect ratio
                       'showPreview'                  => true,
                       //false to hide the preview
                       'showDeletePickedImageConfirm' => false,
                       //on true show warning before detach image
593851ec   Alexey Boroda   First commit
160
161
                   ]
               ); ?>
ee588281   Alexey Boroda   -Blog backend ready
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    
    <div class="form-group">
      <label class="control-label"><?= \Yii::t('blog', 'Articles'); ?></label>
        <?php
            if ($model->isNewRecord) {
                $condition = '';
            } else {
                $condition = ', id: ' . $model->id;
            }
            echo Select2::widget(
                [
                    'name'          => 'articleIds',
                    'options'       => [
                        'placeholder' => \Yii::t('blog', 'Search for an articles ...'),
                        'multiple'    => true,
                    ],
                    'value'         => array_keys($model->articleIds),
                    'data'          => $model->articleIds,
                    'pluginOptions' => [
                        'allowClear'         => true,
                        'minimumInputLength' => 3,
                        'language'           => [
                            'errorLoading' => new JsExpression(
                                "function () { return 'Waiting for results...'; }"
                            ),
                        ],
                        'ajax'               => [
                            'url'      => Url::to([ '/blog-article/list' ]),
                            'dataType' => 'json',
                            'data'     => new JsExpression(
                                'function(params) { 
                                      return {
                                          q:params.term' . $condition . '
                                      }; 
                                   }'
                            ),
                        ],
                        'escapeMarkup'       => new JsExpression(
                            'function (markup) {
                                  return markup; 
                               }'
                        ),
                        'templateResult'     => new JsExpression(
                            'function (brand) { 
                                  return brand.text; 
                               }'
                        ),
                        'templateSelection'  => new JsExpression(
                            'function (brand) {
                                  return brand.text; 
                               }'
                        ),
                    ],
                ]
            );
        ?>
    </div>
d7bd5725   Yarik   Blog article to p...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
      <?php
          if (class_exists('\artbox\catalog\models\Product')) {
              ?>
            <div class="form-group">
              <label class="control-label"><?= \Yii::t('blog', 'Products'); ?></label>
                <?php
                    echo Select2::widget(
                        [
                            'name'          => 'productIds',
                            'options'       => [
                                'placeholder' => \Yii::t('blog', 'Search for products ...'),
                                'multiple'    => true,
                            ],
                            'value'         => array_keys($model->productIds),
                            'data'          => $model->productIds,
                            'pluginOptions' => [
                                'allowClear'         => true,
                                'minimumInputLength' => 3,
                                'language'           => [
                                    'errorLoading' => new JsExpression(
                                        "function () { return 'Waiting for results...'; }"
                                    ),
                                ],
                                'ajax'               => [
                                    'url'      => Url::to([ '/product/list' ]),
                                    'dataType' => 'json',
                                    'data'     => new JsExpression(
                                        'function(params) {
                                      return {
                                          q:params.term
                                      };
                                   }'
                                    ),
                                ],
                                'escapeMarkup'       => new JsExpression(
                                    'function (markup) {
                                  return markup;
                               }'
                                ),
                                'templateResult'     => new JsExpression(
                                    'function (product) {
                                  return product.text;
                               }'
                                ),
                                'templateSelection'  => new JsExpression(
                                    'function (product) {
                                  return product.text;
                               }'
                                ),
                            ],
                        ]
                    );
                ?>
            </div>
              <?php
          }
      ?>
593851ec   Alexey Boroda   First commit
276
277
278
279
280
      
      <?= $form->field($model, 'sort')
               ->textInput() ?>
      
      <?= $form->field($model, 'status')
ba196ec2   Alexey Boroda   -Blog in process
281
282
283
284
285
               ->checkbox(
                   [
                       'class' => 'flat',
                   ]
               ) ?>
593851ec   Alexey Boroda   First commit
286
287
288
      
      <?= $form->field($model, 'author_id')
               ->textInput() ?>
ee588281   Alexey Boroda   -Blog backend ready
289
290
291
292
293
294
295
    
    <div class="form-group">
        <?= Html::submitButton(
            $model->isNewRecord ? 'Create' : 'Update',
            [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
        ) ?>
    </div>
593851ec   Alexey Boroda   First commit
296
297
298
299
      
      <?php ActiveForm::end(); ?>
  
  </div>