_form.php
7.85 KB
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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
use artbox\weblog\models\Article;
use artbox\weblog\models\ArticleLang;
// use artweb\artbox\blog\models\BlogCategory;
// use artweb\artbox\blog\models\BlogTag;
use kartik\select2\Select2;
use noam148\imagemanager\components\ImageManagerInputWidget;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;
use yii\widgets\ActiveForm;
use artbox\core\widgets\LanguageForm;
use yii\web\JsExpression;
/**
* @var View $this
* @var Article $model
* @var ActiveForm $form
* @var ArticleLang[] $modelLangs
* @var BlogCategory[] $categories
* @var BlogTag[] $tags
* @var array $products
* @var array $articles
*/
?>
<div class="blog-article-form">
<?php $form = ActiveForm::begin(
[
'options' => [ 'enctype' => 'multipart/form-data' ],
]
); ?>
<?php
echo LanguageForm::widget(
[
'modelLangs' => $modelLangs,
'formView' => '@artbox/weblog/views/blog-article/_form_language',
'form' => $form,
]
);
?>
<?php
// echo $form->field($model, 'blogCategories')
// ->widget(
// Select2::className(),
// [
// 'data' => $categories,
// 'theme' => Select2::THEME_BOOTSTRAP,
// 'options' => [
// 'placeholder' => \Yii::t('blog', 'Select category'),
// 'multiple' => true,
// ],
// 'pluginOptions' => [
// 'allowClear' => true,
// ],
// ]
// );
?>
<?php
// echo $form->field($model, 'blogTags')
// ->widget(
// Select2::className(),
// [
// 'data' => $tags,
// 'theme' => Select2::THEME_BOOTSTRAP,
// 'options' => [
// 'placeholder' => \Yii::t('blog', 'Select tag'),
// 'multiple' => true,
// ],
// 'pluginOptions' => [
// 'allowClear' => true,
// ],
// ]
// );
?>
<?= $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
]
); ?>
<?php
// echo $form->field($model, 'products')
// ->widget(
// Select2::className(),
// [
// 'data' => $products,
// 'options' => [
// 'placeholder' => \Yii::t('blog', 'Select related products'),
// 'multiple' => true,
// ],
// 'pluginOptions' => [
// 'allowClear' => true,
// 'minimumInputLength' => 3,
// 'language' => [
// 'errorLoading' => new JsExpression(
// "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }"
// ),
// ],
// 'ajax' => [
// 'url' => yii\helpers\Url::to([ '/blog/blog-article/product-list' ]),
// 'dataType' => 'json',
// 'data' => new JsExpression('function(params) { return {q:params.term}; }'),
// ],
// 'templateResult' => new JsExpression('function(product) { return product.text; }'),
// 'templateSelection' => new JsExpression('function (product) { return product.text; }'),
// ],
// ]
// );
?>
<?php
// if (empty( $model->id )) {
// $data = 'function(params) { return {q:params.term}; }';
// } else {
// $data = 'function(params) { return {q:params.term, id:' . $model->id . '}; }';
// }
// echo $form->field($model, 'blogArticles')
// ->widget(
// Select2::className(),
// [
// 'data' => $articles,
// 'options' => [
// 'placeholder' => \Yii::t('blog', 'Select related articles'),
// 'multiple' => true,
// ],
// 'pluginOptions' => [
// 'allowClear' => true,
// 'minimumInputLength' => 3,
// 'language' => [
// 'errorLoading' => new JsExpression(
// "function () { return '" . \Yii::t('blog', 'Waiting for results') . "'; }"
// ),
// ],
// 'ajax' => [
// 'url' => yii\helpers\Url::to([ '/blog/blog-article/article-list' ]),
// 'dataType' => 'json',
// 'data' => new JsExpression(
// $data
// ),
// ],
// 'templateResult' => new JsExpression('function(article) { return article.text; }'),
// 'templateSelection' => new JsExpression('function (article) { return article.text; }'),
// ],
// ]
// );
?>
<?= $form->field($model, 'sort')
->textInput() ?>
<?= $form->field($model, 'status')
->checkbox(
[
'class' => 'flat',
]
) ?>
<?= $form->field($model, 'author_id')
->textInput() ?>
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? 'Create' : 'Update',
[ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>