_form.php
3.46 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
<?php
use artbox\core\admin\assets\Switchery;
use artbox\core\helpers\ImageHelper;
use dosamigos\tinymce\TinyMce;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\JsExpression;
use yii\web\View;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model \common\models\Book */
/* @var $form yii\widgets\ActiveForm */
Switchery::register($this);
$js = <<< JS
$('.switchery').each(function(idx, elem) {
new Switchery(elem, {
color:'#46b749',
secondaryColor:'#e2e2e2'
});
});
JS;
$this->registerJs($js, View::POS_READY);
?>
<div class="feedback-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')
->textInput([ 'maxlength' => true ]) ?>
<div class="form-group">
<?=ImageHelper::set('@storage/books/'.$model->id.'/'.$model->image)->cropResize(262, 390)->renderImage()?>
</div>
<?=$model->author->name.' '.$model->author->secondname?>
<?= $form->field($model, 'description')
->widget(
TinyMce::className(),
[
'options' => [ 'rows' => 30 ],
'language' => 'ru',
'clientOptions' => [
'file_browser_callback' => new JsExpression(
"function(field_name, url, type, win) {
window.open('" . Url::to(
[
'imagemanager/manager',
'view-mode' => 'iframe',
'select-type' => 'tinymce',
]
) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
}"
),
'plugins' => [
"advlist autolink lists link charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste image",
],
'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code",
'image_advtab' => true,
],
]
); ?>
<?= $form->field($model, 'preview')
->textarea(
[
'rows' => '10',
]
) ?>
<?= $form->field($model, 'status')->widget(
Select2::classname(),
[
'data' => $model->getStatuses(),
'pluginOptions' => [
'allowClear' => true,
],
]
);
?>
<?= $form->field($model, 'price')
->textInput() ?>
<?= $form->field($model, 'on_main')
->checkbox(
[
'class' => 'switchery',
]
) ?>
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'),
[ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>