_form.php
5.25 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
<?php
use artweb\artbox\components\artboximage\ArtboxImageHelper;
use artweb\artbox\language\widgets\LanguageForm;
use artweb\artbox\ecommerce\models\Category;
use artweb\artbox\ecommerce\models\CategoryLang;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;
use yii\widgets\ActiveForm;
/**
* @var View $this
* @var Category $model
* @var CategoryLang[] $modelLangs
* @var string[] $categories
* @var ActiveForm $form
* @var array $parents
*/
?>
<div class="category-form">
<?php $form = ActiveForm::begin(
[
'enableClientValidation' => false,
'options' => [ 'enctype' => 'multipart/form-data' ],
]
); ?>
<?= $form->field($model, 'parent_id')
->dropDownList(
$parents,
[
'prompt' => Yii::t('rubrication', 'Root category'),
'options' => [
$model->id => [ 'disabled' => true ],
],
]
)
->label(Yii::t('product', 'Parent category')) ?>
<?php
echo $form->field($model, 'sort');
?>
<?php
echo $form->field($model, 'sort2');
?>
<?= $form->field($model, 'image')
->widget(
\kartik\file\FileInput::className(),
[
'language' => 'ru',
'options' => [
'accept' => 'image/*',
'multiple' => false,
'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-image', 'id' => $model->id]),
'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
'jpg',
'gif',
'png',
],
'initialPreview' => !empty( $model->getImageUrl(0, false) ) ? ArtboxImageHelper::getImage(
$model->imageUrl,
'list'
) : '',
'initialPreviewShowDelete' => false,
'overwriteInitial' => true,
'showRemove' => true,
'showUpload' => false,
'showClose' => false,
'previewFileType' => 'image',
],
]
); ?>
<?= $form->field($model, 'icon')
->widget(
\kartik\file\FileInput::className(),
[
'language' => 'ru',
'options' => [
'accept' => 'image/*',
'multiple' => false,
'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-icon', 'id' => $model->id]),
'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
'jpg',
'gif',
'png',
],
'initialPreview' => !empty( $model->getImageUrl(
1,
false
) ) ? ArtboxImageHelper::getImage(
$model->getImageUrl(1, false),
'list'
) : '',
'initialPreviewShowDelete' => false,
'overwriteInitial' => true,
'showRemove' => true,
'showUpload' => false,
'showClose' => false,
'previewFileType' => 'image',
],
]
); ?>
<?= LanguageForm::widget(
[
'modelLangs' => $modelLangs,
'formView' => '@artweb/artbox/ecommerce/views/category/_form_language',
'form' => $form,
]
) ?>
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'),
[ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
) ?>
<?php if ($model->isNewRecord) : ?>
<?= Html::submitButton(
Yii::t('product', 'Create and continue'),
[
'name' => 'create_and_new',
'class' => 'btn btn-primary',
]
) ?>
<?php endif ?>
</div>
<?php ActiveForm::end(); ?>
</div>