_form.php
1.88 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
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\jui\AutoComplete;
/* @var $this yii\web\View */
/* @var $model common\modules\rubrication\models\TaxGroup */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="relation-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, $relation['entity1']['linked_key'])->widget(
AutoComplete::className(), [
// 'model' => \common\modules\relation\models\Relation::className(),
'clientOptions' => [
'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity1']),
'dataType' => 'json',
'autoFill' => true,
'minLength' => '2',
],
'options' => [
'value' => empty($value1) ? '' : $value1,
'class'=>'form-control',
'placeholder' => $relation['entity1']['label']
]
]);
?>
<?= $form->field($model, $relation['entity2']['linked_key'])->widget(
AutoComplete::className(), [
// 'model' => \common\modules\relation\models\Relation::className(),
'clientOptions' => [
'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity2']),
'dataType' => 'json',
'autoFill' => true,
'minLength' => '2',
'allowClear' => true,
],
'options' => [
'value' => empty($value2) ? '' : $value2,
'class'=>'form-control',
'placeholder' => $relation['entity2']['label']
]
]);
?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('relation', 'Create') : Yii::t('relation', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>