1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* @var View */ |
4
|
|
|
/* @var $model hipanel\modules\hosting\models\Service */ |
5
|
|
|
/* @var $softs array */ |
6
|
|
|
/* @var $states array */ |
7
|
|
|
|
8
|
|
|
use hipanel\modules\client\widgets\combo\ClientCombo; |
9
|
|
|
use hipanel\modules\hosting\widgets\ip\ServiceIpCombo; |
10
|
|
|
use hipanel\modules\server\models\Server; |
11
|
|
|
use hipanel\modules\server\widgets\combo\PanelServerCombo; |
12
|
|
|
use yii\helpers\Html; |
13
|
|
|
use yii\bootstrap\ActiveForm; |
14
|
|
|
use yii\helpers\Url; |
15
|
|
|
use yii\web\View; |
16
|
|
|
|
17
|
|
|
$form = ActiveForm::begin([ |
18
|
|
|
'id' => 'dynamic-form', |
19
|
|
|
'enableClientValidation' => true, |
20
|
|
|
'validateOnBlur' => true, |
21
|
|
|
'enableAjaxValidation' => true, |
22
|
|
|
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->isNewRecord ? $model->scenario : 'update']), |
23
|
|
|
]) ?> |
24
|
|
|
|
25
|
|
|
<div class="container-items"><!-- widgetContainer --> |
26
|
|
|
<?php foreach ($models as $i => $model) { ?> |
27
|
|
|
<div class="row"> |
28
|
|
|
<div class="col-md-4"> |
29
|
|
|
<div class="box box-danger"> |
30
|
|
|
<div class="box-body"> |
31
|
|
|
<div class="form-instance" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html"> |
32
|
|
|
<?php |
33
|
|
|
if (!$model->isNewRecord) { |
34
|
|
|
print Html::activeHiddenInput($model, "[$i]id"); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
if (Yii::$app->user->can('support')) { |
|
|
|
|
38
|
|
|
print $form->field($model, "[$i]client")->widget(ClientCombo::class, [ |
39
|
|
|
'formElementSelector' => '.form-instance', |
40
|
|
|
'inputOptions' => [ |
41
|
|
|
'readonly' => !$model->isNewRecord |
42
|
|
|
] |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
print $form->field($model, "[$i]server")->widget(PanelServerCombo::class, [ |
47
|
|
|
'formElementSelector' => '.form-instance', |
48
|
|
|
'state' => Server::STATE_OK, |
49
|
|
|
'inputOptions' => [ |
50
|
|
|
'readonly' => !$model->isNewRecord |
51
|
|
|
] |
52
|
|
|
]); |
53
|
|
|
|
54
|
|
|
print $form->field($model, "[$i]name"); |
55
|
|
|
|
56
|
|
|
$ips = array_unique(array_merge((array)$model->ip, (array)$model->ips)); |
57
|
|
|
print $form->field($model, "[$i]ips")->widget(ServiceIpCombo::class, [ |
58
|
|
|
'formElementSelector' => '.form-instance', |
59
|
|
|
'current' => array_combine($ips, $ips), |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
print $form->field($model, "[$i]bin"); |
63
|
|
|
print $form->field($model, "[$i]etc"); |
64
|
|
|
|
65
|
|
|
print $form->field($model, "[$i]soft")->dropDownList($softs); |
66
|
|
|
print $form->field($model, "[$i]state")->dropDownList($states); |
67
|
|
|
?> |
68
|
|
|
</div> |
69
|
|
|
</div> |
70
|
|
|
</div> |
71
|
|
|
</div> |
72
|
|
|
</div> |
73
|
|
|
<?php } ?> |
74
|
|
|
</div> |
75
|
|
|
<?= Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success']) ?> |
76
|
|
|
|
77
|
|
|
<?= Html::button(Yii::t('hipanel', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?> |
78
|
|
|
|
79
|
|
|
<?php ActiveForm::end(); |
80
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.